This is the segment of code I used, note the **** is the replacement for my name
using System;
using ArduinoUploader;
using ArduinoUploader.Hardware;
namespace SoftwareAssignment
{
class Program
{
static void Main(string[] args)
{
var uploader = new ArduinoSketchUploader(
new ArduinoSketchUploaderOptions()
{
FileName = #"C:\Users\****\OneDrive\Desktop\Blink\Blink.hex",
PortName = "COM5",
ArduinoModel = ArduinoModel.Micro
});
uploader.UploadSketch();
}
}
I recieved the exception whilst using the ArduinoUploader to upload a .hex file onto an arduino whilst in Visual Studio 2019.
System.IO.FileLoadException: 'Could not load file or assembly 'IntelHexFormatReader, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)'
These are the details
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'IntelHexFormatReader, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
Source=ArduinoUploader
StackTrace:
at ArduinoUploader.ArduinoSketchUploader.UploadSketch(IEnumerable`1 hexFileContents)
at ArduinoUploader.ArduinoSketchUploader.UploadSketch()
at SoftwareAssignment.Program.Main(String[] args) in C:\Users\****\source\repos\SoftwareAssignment\SoftwareAssignment\Program.cs:line 20
I do not know how I should go around troubleshooting this or if it is a resultant of the ArduinoUploader package using an older verison of the .NET framework, or if there is anyway to fix this at all. The code is written in C#.
You can rebind assemblies in many ways, the easiest for me personally is in the config file. Below from
https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions
<dependentAssembly>
<assemblyIdentity name="someAssembly"
publicKeyToken="32ab4ba45e0a69a1"
culture="en-us" />
<bindingRedirect oldVersion="7.0.0.0"
newVersion="8.0.0.0" />
</dependentAssembly>
Do note however that there are no guarantees the assembly you have will work as you expect, be it older or newer. I'd suggest you try to find the right one. That said, if you can't, then above is your best shot.
I hear you OP. You must understand that you need to install another NuGet package, that being IntelHexReader. Its written by the same lad, TwinEarthSoftware. Search for it in Visual Studio. You don't need to inculde it when defining the directories used. The has nothing to do with.NET framework, its just suggesting that it needs 2.2.3.0 of the IntelHexFileReader.
Related
I've been using Mailkit 2.15 and now trying to upgrade to v3.4.1. When I upgraded, all its dependencies got installed including System.Runtime.CompilerServices.Unsafe v4.5.3. But when I execute the code, the following exception occurs.
13-Oct-2022 16:33:19,303 [INFO ] Mail SendEmail - System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Span`1..ctor(T[] array)
at MimeKit.Utils.ValueStringBuilder..ctor(Int32 initialCapacity)
at MimeKit.Utils.Rfc2047.Encode(FormatOptions options, Encoding charset, String text, Boolean phrase)
at MimeKit.Header.EncodeUnstructuredHeader(ParserOptions options, FormatOptions format, Encoding encoding, String field, String value)
at MimeKit.Header.EncodeAddressHeader(ParserOptions options, FormatOptions format, Encoding encoding, String field, String value)
at MimeKit.Header.FormatRawValue(FormatOptions format, Encoding encoding, String value)
at MimeKit.Header.SetValue(FormatOptions format, Encoding encoding, String value)
at MimeKit.Header..ctor(Encoding encoding, HeaderId id, String value)
at MimeKit.HeaderList.set_Item(HeaderId id, String value)
at MimeKit.MimeMessage..ctor()
When I investigated further, I noticed that the MimeKit requires System.Memory and the System.Memory installed System.Runtime.CompilerServices.Unsafe v4.5.3. But I'm not sure why [System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1] is still required.
Note: Prior to Mailkit 3.4.1 upgrade, my project does not depend on System.Runtime.CompilerServices.Unsafe and it is not listed in the references.
I'm running into this exact same issue with a .NET 4.7.2 project. In my case we are pulling external email functionality into our solution. We are adding a new project that will process email using MailKit. I got the same error as you and tried downgrading to MailKit 3.1.1 which appears to be the last version without the chain of dependencies (including MimeKit) that requires System.Runtime.CompilerServices.Unsafe.
I completely uninstalled MailKit and all of its dependencies and installed the 3.1.1 version. It is working for me so far. I don't have any need to use the latest version of MailKit, so using 3.1.1 for now works.
In my case, the source of the error appears to be that one of the other projects in the solution is using an older version of System.Runtime.CompilerServices.Unsafe which is generating a conflict. I'd have to do more research in order to figure out how to integrate separate versions of this package into a single solution.
This issue is apparently a known bug in the core MSBuild targets, perhaps because of the inconsistent versioning scheme that System.Runtime.CompilerServices.Unsafe uses(?). I'm not entirely clear on what the problem is. It also sounds like the issue has been fixed in newer versions of the MSBuild targets (newer versions of Visual Studio?).
In any case, adding the following App.Config file to your project should resolve the problem with assembly resolution:
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="4.0.4.1" />
</dependentAssembly>
Another possibility is to try upgrading Visual Studio (although I'm not sure if that would work or not).
I am writing an Add-in for Visual Studio 2017. I use the following:
Dispatcher.CurrentDispatcher.Invoke(()=>
{
// ...
});
But I keep getting the compiler warning: VSTHRD001 Avoid legacy thread switching methods and since I can be a bit obsessive, I researched the warning, and applied the "fix":
ThreadHelper.JoinableTaskFactory.Run(()=>
{
// ...
});
Since applying the fix, the method won't even run, upon further investigation, it's throwing the error: 'Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=15.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
I'm using the nuget package <package id="Microsoft.VisualStudio.Threading" version="15.7.18" targetFramework="net461" /> and I have the binding redirects from installing the package in my app.config: <bindingRedirect oldVersion="0.0.0.0-15.7.0.0" newVersion="15.7.0.0" />
I've downgraded the package and even tried changing the redirect version but to no avail. For the only other similar related issue, Microsoft insists it's not a bug.
I'm using Visual studio 15.7.3 and that dll in the C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PrivateAssemblies is version 15.6.27-beta+gca...
Any ideas? Yes Dispatcher.CurrentDispatcher.Invoke works perfect.
I got an app with server code, now I try to run it on Photon Server, but I receive an exception with PhotonHostRuntimeInterfaces, I guess there is something wrong with version, I searched a lot for such a problem, but I'm really new in server programming, so can anyone help me with this issue?
Here is the log:
*System.Exception: Stop: unable to call the Application.TearDown() - undefined photonControl.
в PhotonHostRuntime.PhotonDomainManager.PhotonPlainAppDomainBehavior.Stop()
в PhotonHostRuntime.PhotonDomainManager.Stop()
6336: 10:34:55.862 - ERROR: Failed to start application: "RagingServer" in app domain: 2
6336: 10:34:55.863 - CService::OnException() - Exception: CManagedHost::StartApplication() - Failed to start application in AppDomain: 2 - Could not load file or assembly "PhotonHostRuntimeInterfaces, Version=3.56.0.0, Culture=neutral, PublicKeyToken=6cb1467adaa73020"or one of their dependencies. The obtained assembly manifest definition does not match the assembly reference (Исключение из HRESULT: 0x80131040)
6336: 10:34:55.863 - Server shutting down...*
I also found a solution like that:
<dependentAssembly>
<assemblyIdentity name="PhotonHostRuntimeInterfaces" publicKeyToken="6cb1467adaa73020" culture="neutral" />
<bindingRedirect oldVersion="3.56.0.0" newVersion="3.58.0.0" />
</dependentAssembly>
But I'm not sure where I should put in it, on my PhotonServer.config?
this is usually placed into your application config, which looks like AssemblyName.dll.config. take a look here for examples and docs
and you back to your problem, there is at least two options:
1. you mixed sdk versions. Photon SDK version v3.4.27 is using PhotonHostRuntimeInterfaces.dll, Version=3.56.0.0. You may find it in sdk lib folder and in 'deploy\bin_Win64'. newer versions of sdk use version 3.58 of PhotonHostRuntimeInterfaces.dll. Probable you upgraded your developer machine, but did not upgrade your server
you forgot to add this dll at all. it should be in bin folder of your application
hope this will help you
-The Photonians
After upgrading mvc nuget package from version 5.1.0 to 5.2.2 our machine (webrole) on Azure refuses to start the web role. It was in recycling state. I found an error in event log :
The description for Event ID 1007 from source Windows Azure Runtime 2.4.0.0 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
820
WaIISHost
Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
the message resource is present but the message is not found in the string/message table
I tried to search over the internet, but with no useful answer.
I wasn't able to solve it otherwise than downgrade. Luckily package version 5.1.1 is working.
Update 1:
After some trial and error I found, that asp.net mvc packages are OK up to version 5.1.3
It looks like packages from 5.2.0 upwards are not supported.
Update 2:
We have decided to split our web and web.api, so I didn't have this problem anymore. My best guess is, that there was indeed nuget, which was referencing older asp.net mvc package.
I had a similar problem. We inherited a project and updated the ASPNET MVC version to 5.2.2.0. We couldn't deploy to Azure. The only error we could find was the one you mentioned here.
We corrected every web.config file so older versions were redirected to a newer version but we still had the same problem.
Then we wrote a small test method that iterated over every Assembly and we saw that one NuGet package was still using Asp.net MVC 4.0. This package was an old version and hadn't been updated for a while. I downloaded the source, updated the Mvc Nuget and manually inserted the dll.
We deployed again and everything went flawless.
Here is are test method.
private void TestAssemblies()
{
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly item in allAssemblies)
{
PrintAssembly(item);
}
}
private void PrintAssembly(Assembly assembly)
{
foreach (var item in assembly.GetReferencedAssemblies())
{
if (item.FullName.Contains("System.Web.Mvc"))
{
Debug.WriteLine(item);
Debug.WriteLine("Parent: " + assembly.FullName);
Debug.WriteLine("------------------------------------------------------------");
}
}
}
MVC 5.2.2 works perfectly fine in Azure. Your role recycling is most likely an indication that either you have not properly deployed your application properly or that you have a hidden dependency on an older version of MVC that a binding redirect may not handle.
I would strongly suggest that you read all of the entries in Kevin Williamson's great series on trouble shooting Azure deployments.
There are a ton of things that can go wrong, so rather than try to create a generic one-size-fits-all list, review the blog posts and then post a comment if you are unable to figure out what specifically is happening.
Given the error that you did post, assuming you have the proper binding redirect that #Yishai Galatzer mentions, you might have a DLL in your deployment that has a hidden dependency on MVC 5.1.0.0. I would suggest using a program like Jetbrains DotPeek to inspect all of your DLLs in your package and look at their references. I suspect you'll find one that itself depends on 5.1.0.0.
I have also face similar problem with mvc5.2.2 azure deployment..
the ultimate solution is we need to add this web.config
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>``
From the looks of it, looks like you are missing a binding redirect to MVC 5.2.2 in your web.config. This should just work.
We are working on verifying this scenario. But let us know if this works for you. In your web.config please take a look at the following section, and makes sure it matches with this xml below:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
I had exactly similar problem couple of days back. Please refer to this post.
You need to add <dependentAssembly> section to WaIISHost.exe.config which is generally # 'E:\base\x64' on your VM.
Many times I've found the problem to be in the ~\Views\Web.config file. It keeps a reference to the old MVC version. Just manually update it.
If that doesn't work do a full text search of your solution in Sublime Text or some other tool outside of VS and search for the version string causing you issues.
I had the same issue, where it worked fine on my Dev machine, but when deployed I was getting the assembly error. To resolve this, I had to change the "oldVersion" from version 0.0.0.0 to version 1.0.0.0
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
To
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
I am using visual studio 2010 ultimate. I have got the following error when I try to import a dynamic data linq to sql website project on my computer:
------ Rebuild All started: Project: C:...\TestVersion99Website\, Configuration: Debug Any CPU ------ Validating Web Site Building
directory '/TestVersion99Website/App_Code/'. Building directory
'/TestVersion99Website/DynamicData/Content/'. Building directory
'/TestVersion99Website/DynamicData/FieldTemplates/'.
C:\Users\Test\Documents\Visual Studio
2010\WebSites\TestVersion99Website\DynamicData\FieldTemplates\MultilineText_Edit.ascx(7):
Build (web): Could not load file or assembly 'System.Web.DynamicData,
Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
... C:\Users\Test\Documents\Visual Studio
2010\WebSites\TestVersion99Website\DynamicData\FieldTemplates\Text_Edit.ascx(7):
Build (web): Could not load file or assembly 'System.Web.DynamicData,
Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
Validation Complete
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
The website was written using .net 3.5 sp1 framework. The System.Web.DynamicData assembly was from DynamicData 4 preview project from codeplex.
To identify the error, I have created a new dynamic data linq to sql website project using .net 3.5 framework. Once the website is built, I removed the reference to "System.Web.Dynamicdata 3.5.0.0". I created a new Bin folder, and copied the assembly "Microsoft.Web.Extensions 99.0.0.0, System.ComponentModel.DataAnnotations 99.0.0.0, System.Web.DynamicData 99.0.0.0" into the Bin folder. I then made sure that in web.config the assembly versions are changed to 99.0.0.0. However, When I tried to build the solution, I still had the same error messages. I have no idea why this is happening and am really really very frustrated.
Check for any bindingRedirect you have in your web.config.
<dependentAssembly>
<assemblyIdentity name="System.Web.DynamicData" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="3.5.0.0" newVersion="99.0.0"/>
</dependentAssembly>