May 15, 2019 TypeLoadException says 'no implementation', but it is implemented. This is because without this flag, the method does not implement the interface. Method does not have an implementation when loading assemblies into a new AppDomain in ReflectionOnly mode.
, No its not the case, if all functions are in the same Dll then one DllImport attribute is enough. You can write DllImport once and call all function of that dll. And you dont have to write this above each function.I believe you are incorrect:-), without decorating each method with the DllImport attribute then there is no way for the CLR to know which DLL to link the external method to. I just wrote a quick test where I called an external method which did not have the DllImport attribute and another in the same class did (both methods came frm the same DLL) and I got the exact same error as the OP (excluding my class specific names):Could not load type 'ShowMeHowI.DesktopCapturer' from assembly 'ShowMeHowI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the method 'BitBlt' has no implementation (no RVA).Mark.
Mark Dawson wrote:, No its not the case, if all functions are in the same Dll then one DllImport attribute is enough. You can write DllImport once and call all function of that dll. And you dont have to write this above each function.I believe you are incorrect:-), without decorating each method with the DllImport attribute then there is no way for the CLR to know which DLL to link the external method to.
I created a netstandard1.4 library (csproj) which uses System.Net.Http, and the highest available netstandard1.3 listed in NETStandard.Library meta package references System.Net.Http v4.1.0.I reference this library from a.Net Core console app which targets net461, and the latter has System.Net.Http v4.0.0.0 in GAC. During build I get a warning regarding library versions conflict, and at run time get a FileNoFoundException: 'Could not load file or assembly 'System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.' Also, in project references (in solution explorer) System.Net.Http v4.0.0 is shown. This looks pretty confusing, since I expect that once I referenced NETStandard.Library and target netstandard, I should not care about such versions consistency, since.NET Platform Standard docs claim that netstandard 1.4 is supported by net461 and higher, and netstandard 1.3 is supported by net46 and higher.UPDATE: I was also able to reproduce this problem when the library is xproj-based. Cc:One thing to keep in mind is that with the System.Net.Http 4.1 NuGet package, System.Net.Http is completely an OOB package. Even on.NET Framework (Desktop), using the System.Net.Http 4.1 package replaces the use of the.NET Framework System.Net.Http binary in the GAC. This is unlike most of the other CoreFx packages on Desktop which are facades and actually use the GAC'd binaries.We OOB'd System.Net.Http in CoreFx in order to provide a more expansive API surface that would work against.NET Standard 1.3 and above.I'm not sure if this totally relates to the problem you are experiencing but it might be related to the version conflicts you appear to see.
I have an old project (C#,.Net 4.6.1). We replaced at one moment the references to System.Net.Http for the NuGet package (v4.1.0.0) but when trying to create new HttpConfiguration it would invariably fail when trying to create the JsonMediaTypeFormatter internally.The internal error is actually thrown when the JsonMediaTypeFormatter constructor tries to get the JSON MediaTypeHeaderValue which is generated via cloning. Maybe I didn't express myself with clarity before.When we use.NET's 4.6.1 out-of-the-box version of System.Net.Http (v4.0.0.0) everything works fine with the System.Net.Http.Formatting library.When we use the corefx version (v4.1.0.0) via NuGet, it fails. The error is the one above, hinting that the ICloneable interface is not the same because it does not fulfill the type parameter constraint at CloneableExtensions.When we revert to v4.0.0.0 things start working again.Therefore, v4.1.0.0 distributed by NuGet of the System.Net.Http dll is not an OOB package as it breaks compatibility with other packages that, when using v4.0.0.0, work fine.I'd love to use NuGet's version and get earlier and faster updates, but we can't because of this. I will create a new one specifically for this, then, if that's better.This said, the abovementioned issue was exactly the same one we had when trying to revert to v4.0.0.0 after finding out that v4.1.0.0 is not an OOB package. Visual Studio kept the 4.1.0.0 references even though all NuGet package references and assembly redirections had been removed. The only workaround was to remove the reference altogether and add it again from the installed.NET 4.6.1 set of DLLs in every project using it.
I seem to be encountering something similar. I've got a set of libraries all build targeting net4.5.2 and I can run those fine in their test harnesses (usually console exe) and unit tests. I am not trying to consume a number of them in a console exe that provides a SignalR hub, targeting net4.5.2. I can build fine (ignoring the version conflicts for now which have to do with Owin and Http), at runtime I get the same could not load file or assembly error, but in my case it is System.ComponentModel.TypeConverter. When I look in the bin folder, I see that DLL there, but inspecting it with PowerShell ( System.Reflection.Assembly::LoadFrom('.' ).GetName.Version) I see it is version 4.0.0.0. Looking at the for that assembly it appears as though the packaging is different between 4.5 and 4.6.
Inspecting the NuGet package itself confirms that the net452 folder has version 4.0.0.0 while net462 contains version 4.1.0.0.What is most odd about it is that the test harness for one of the libraries shows version 4.0.0 of the type converter assembly in the bin folder and it runs just fine. 4.1.0.0 is the expected version.
Try adding a binding redirect to solve the file-not-found at runtime.Solution explorer is likely showing some direct assembly reference (eg: simple name reference or FrameworkAssembly reference from a NuGet package) this gets trimmed by targets that run at build. /ccFrom: colin-young mailto:[email protected]: Thursday, July 7, 2016 8:57 AMTo: dotnet/corefx [email protected]: Eric St. John [email protected]; Mention [email protected]: Re: dotnet/corefx.Net Plaform Standard implementation on.Net 4.6.1 has version inconsistency for System.Net.Http I seem to be encountering something similar. I've got a set of libraries all build targeting net4.5.2 and I can run those fine in their test harnesses (usually console exe) and unit tests. I am not trying to consume a number of them in a console exe that provides a SignalR hub, targeting net4.5.2. I can build fine (ignoring the version conflicts for now which have to do with Owin and Http), at runtime I get the same could not load file or assembly error, but in my case it is System.ComponentModel.TypeConverter.
When I look in the bin folder, I see that DLL there, but inspecting it with PowerShell (System.Reflection.Assembly::LoadFrom('.' ).GetName.Version) I see it is version 4.0.0.0. Looking at the sourcefor that assembly it appears as though the packaging is different between 4.5 and 4.6.
Inspecting the NuGet package itself confirms that the net452 folder has version 4.0.0.0 while net462 contains version 4.1.0.0.What is most odd about it is that the test harness for one of the libraries shows version 4.0.0 of the type converter assembly in the bin folder and it runs just fine.—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHubor mute the threadhttps://github.com/notifications/unsubscribe/AIgUXGQ2FQvlm1Iahq8TaQzV9zIWYO7mks5qTSGxgaJpZM4JE8Nf. This: did the trick. The existing binding tried to map to 4.0.1.0 instead. It appears that it was added automatically when I updated NuGet references to the RTM bits, since my csproj has AutoGenerateBindingRedirects set to true. I can't figure out where the redirection versions are defined, so I'm not entirely sure where the source of the problem is.For the record, Solution Explorer isn't showing TypeConverter at all.
It's Windows Explorer where I found the DLL. It's included transitively from Microsoft.Extensions.Configuration.Binder. If to make.NET Platform Standard code working correctly on every platform developers will have to do tricks with binding redirects, it will be worst experience ever. This will break the idea of transparent code portability.
![]()
Not to say that in most cases these errors won't be detected until run time (if redirects are not added during package installation).So far, based on previous posts, to me the problem lies in that the tooling doesn't give priority to the System.Net.Http from the package. For some reason it thinks its OOB (GAC) and should not be copied to the output. If GAC's version of the assembly is different to one in the package (apparently it is according to said earlier), I don't see how binding redirect can safely fix the problem. I do have a related issue here:. In that issue I suggest trying a workaround package that forces the auto-generate binding redirects in MSBuild to see a conflict. Try that and see if it works for this case.The place to examine binding redirects written by the build is in the.exe.config in your output directory.If you're seeing that NuGet is modifying the app.config in your source directory, that may be the problem (potentially NuGet bug).
If you have an existing binding redirect in source the auto-generated one will not take precedence. Going back to the original post, and apologies if I've missed some detail since then. I get the same error. If I create a netstandard1.4 class library and add a dependency on the System.Net.Http 4.1.0 nuget package, and then reference the netstandard1.4 class library from a net461 console application, I get a runtime error 'could not load file or assembly System.Net.Http version 4.1.0'.Looking into project.lock.json for the net461 console app, it seems that inside the System.Net.Http 4.10 nuget package there is a frameworkAssemblies reference added to system.net.http 4.0.0 (in the GAC) which I believe is incorrect. It means that the correct System.Net.Http 4.1.0 DLL is not referenced and therefore is not copied to the output folder, causing the runtime error.Again, apologies if the discussion has demonstrated that the frameworkReference to s.net.http 4.0.0 is actually correct. But on the surface the nuspec file for system.net.http 4.1.0 looks possibly buggy for net461 case (and other desktop-framework cases). They are related issues.
Once we fix the System.Net.Http 4.1 package to link against mscorlib, we will also put back ICloneable (since it is available on 'Desktop'). The combination of these fixes will fix the whole problem.The separate issue of ICloneable not being in CoreFx is being handled separately.
That will make pure CoreFx scenarios work better once ICloneable is back in the libraries. But that doesn't impact this issue directly on Desktop, per se.But the fix needed for System.Net.Http 4.1 package is to 'recompile' it for net46 target so that it behaves like a desktop assembly, i.e.
Using reference assemblies mscorlib and not System.Runtime.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |