.net-assembly

Loading DLLs into a separate AppDomain with known only common interface

允我心安 提交于 2020-01-01 06:33:25
问题 I need to load .dll(plugins) in another domain. In main app I don't know anything about plugins types, only that they implement common interface ICommonInterface with some methods. So this code wouldn't help, because I can't create an instance with interface type. AppDomain domain = AppDomain.CreateDomain("New domain name"); //Do other things to the domain like set the security policy string pathToDll = @"C:\myDll.dll"; //Full path to dll you want to load Type t = typeof(TypeIWantToLoad);

Determine the load context of an assembly

百般思念 提交于 2020-01-01 01:56:08
问题 Given a loaded Assembly is there a way (in code) to determine which of the 3 load contexts it was loaded into (default Load , LoadFrom, or Neither )? In Suzanne Cook's "Choosing a Binding Context" article, there are some disadvantages that occur when an assembly is loaded into the LoadFrom . In particular, my library uses deserialization and encounters an InvalidCastException when loaded into the LoadFrom context. Currently my library fails very late (it fails when it executes the problematic

Omit localized versions of assemblies from the build output

女生的网名这么多〃 提交于 2020-01-01 01:41:14
问题 In one of my projects, I am using an awesome library called Humanizer. This library comes in many language variations (I counted 38). When I build my project, I then see all these folders like "af", "ar", "bg", "bn-BD", ..., "zh-Hant" with assemblies containing the localized resources for this library. My issue is that my project is English-only and I have no interest in having all those localized assemblies in my build output. Is there some good way of omitting them from the build? I am

How do I pull DotNetOpenAuth assembly references into unit test project for ASP.NET MVC4 solution?

蓝咒 提交于 2019-12-31 03:55:06
问题 Tl;dr version: I am stuck with the exception: System.IO.FileLoadException : Could not load file or assembly 'DotNetOpenAuth.AspNet, Version 4. 0 .0.0 ... A bit dismayed that msft used so many static classes and methods for auth in the new MVC4 project template. Want to wrap all membership/auth functionality into a class that implements an interface so that I can mock for unit tests. After a couple of evenings of struggling, I have decided to start from scratch, so I removed all DotNetOpenAuth

Why does C# -> CIL have a label on every instruction?

雨燕双飞 提交于 2019-12-31 02:44:10
问题 When using ILDASM.exe on a compiled C# program, it shows that there is a label for every instruction within methods. For example: IL_0001: ldc.i4.4 IL_0002: stloc.0 IL_0003: ldc.r8 12.34 IL_000c: stloc.1 IL_000d: ldc.r8 3.1415926535897931 IL_0016: stloc.2 IL_0017: ldstr "Ehsan" IL_001c: stloc.3 IL_001d: ret Why is this? Is it not inefficient to do this or does the CIL compiler optimize these labels itself? 回答1: Labels are not present in the compiled CIL. They are displayed for your

Turn off warning CS1607

放肆的年华 提交于 2019-12-30 09:47:30
问题 I have a common assembly file where I have tried to turn off a warning: warning CS1607: Assembly generation -- The version '2.0.4.121106' specified for the 'file version' is not in the normal 'major.minor.build.revision' format I have done this but it isn't working: #pragma warning disable 1607 [assembly: AssemblyVersion("2.0.*")] [assembly: AssemblyFileVersion("2.0.4.121106")] [assembly: AssemblyInformationalVersion("2.0.0.0")] #pragma warning restore 1607 So is there some way to do this in

Read Extension of file in resources

故事扮演 提交于 2019-12-30 07:27:09
问题 How can I write a code to read the extension of a My.Resources file? Example: if i have a file named IMG.JPEG in my resources How can I make msgbox to show the extension .JPEG ? I can show the file name but without extension with this For Each Fe In My.Resources.ResourceManager.GetResourceSet _ (System.Globalization.CultureInfo.CurrentCulture, False, True) MsgBox(Fe.Key) Next any help would be greatly appreciated EDIT: I can get the extension of file but as .BYTE[] and pictures as .Bitmap

Assembly Binding Error: Bind result: hr = 0x80070002. The system cannot find the file specified

谁说我不能喝 提交于 2019-12-30 06:11:45
问题 I have a Visual Studio 2010 solution that contains a class library (ProjectA) and two Sharepoint projects (ProjectB & ProjectC). The dependency order is ProjectB references ProejctA and ProjectC references both ProjectA & ProjectB. On one particular development machine i get the following error when trying to build ProjectC: Compilation failed. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. When looking into the fusion log i

Use C# exe to modify resources of a different C# exe

流过昼夜 提交于 2019-12-30 05:06:10
问题 Solved! See below. I have 2 C# applications. Application a is supposed to modify the internal resources of application b. Application b is supposed to do something with its (modified) resources when executed. How can I accomplish that? Here is what I tried: public static void addFileToResources(string dest, string src) { Assembly a_dest = Assembly.LoadFile(dest); using (Stream s_dest = a_dest.GetManifestResourceStream("Elevator.Properties.Resources.resources")) { using (ResourceWriter rw =

BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

安稳与你 提交于 2019-12-30 05:04:00
问题 I am getting following runtime error, with my console application(VS2012) which refers to "dcasdk.dll". .Net Framework of the console app is 4.5, platform target is "Any CPU". Could not load file or assembly 'dcasdk, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. I used CorFlags application to check the target platform of the dll. Below are the details.. Version : v4.0.30319 CLR Header : 2.5 PE