assemblies

Restrict access to .NET assembly?

依然范特西╮ 提交于 2019-12-30 01:23:04
问题 Is there a way to have a .NET assembly accessible for only authorized sources? I mean I want to have a DLL that contains components, but I don't want anyone to be able to use these components but the other DLLs EXEs in my solution. I do want them to be in separated DLLs though. Restriction on namespace might also be a good idea if this feature exists out there. Is there a way? 回答1: You can create internal classes. And the give your specified assemblies to access these classes by using

Is it possible to get the contents of a loaded .net assembly as a byte array or stream?

半城伤御伤魂 提交于 2019-12-29 09:22:41
问题 Is it possible to get the contents of a loaded .net assembly as a byte array or stream? What I'm trying to do is something similar to (of course the real scenario is much more complex, so just storing the buffer is not an option). byte[] bytes = GetTheBytes(); Assembly asm = Assembly.Load(bytes); byte[] bytes2 = GetAssemblyAsByteArray(asm); Assert.IsTrue(bytes.SequenceEqual(bytes2)); I need to know how to implement the GetAssemblyAsByteArray function. Edit: The solution with File.ReadAllBytes

how to use sn.exe -Vr

孤人 提交于 2019-12-29 06:30:15
问题 From the MSDN help, it says the -Vr option is: Registers assembly for verification skipping. My question is when the -Vr is used, will it only change the assembly file itself or it will change the system registry as well. This matters whether I should issue this command in the development machine or in the final deployed machine. 回答1: sn -Vr creates an entry in the registry on the local machine. It does not modify the assembly. You must run sn -Vr locally on every machine on which you wish to

.NET assemblies and DLL rebasing

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 05:21:13
问题 According to this article rebasing is not necessary for .NET assemblies due to JIT compilation of the code. The article states: "JIT-compiled code does not have a rebasing problem since the addresses are generated at run time based on where the code is placed in memory. Also, MSIL is rarely affected by base address misses since MSIL references are token-based, rather than address-based. Thus when the JIT compiler is used, the system is resilient to base address collisions." However, I have

.NET assemblies and DLL rebasing

橙三吉。 提交于 2019-12-29 05:21:08
问题 According to this article rebasing is not necessary for .NET assemblies due to JIT compilation of the code. The article states: "JIT-compiled code does not have a rebasing problem since the addresses are generated at run time based on where the code is placed in memory. Also, MSIL is rarely affected by base address misses since MSIL references are token-based, rather than address-based. Thus when the JIT compiler is used, the system is resilient to base address collisions." However, I have

How to determine whether a DLL is a managed assembly or native (prevent loading a native dll)?

末鹿安然 提交于 2019-12-28 11:51:21
问题 Original title: How can I prevent loading a native dll from a .NET app? Background: My C# application includes a plugin framework and generic plugin loader. The plugin loader enumerates the application directory in order to identify plugin dlls (essentially it searches for *.dll at this time). Within the same application directory is a native (Windows, non-.net) dll, which, indirectly, one of the plugin dlls depends upon. The plugin loader blindly assumes that the native.dll is a .NET

Gacutil.exe successfully adds assembly, but assembly not viewable in explorer. Why?

蹲街弑〆低调 提交于 2019-12-28 04:58:20
问题 I'm running GacUtil.exe from within Visual Studio Command Prompt 2010 to register a dll (CatalogPromotion.dll) to the GAC. After running the utility, it says Assembly Successfully added to the cache , and running gacutil /l CatalogPromotionDll shows that the GAC contains the assembly, but I can't see the assembly when I navigate to C:\WINDOWS\assembly from Windows Explorer. Why can't I see the assembly in WINDOWS\assembly from Windows Explorer but I can see it using gacutil.exe? Background:

Create custom AppDomain and add assemblies to it

大憨熊 提交于 2019-12-28 04:15:11
问题 How can I create an appdomain, add assemblies to it, then destroy that app domain? This is what I have tried: static void Main(string[] args) { string pathToExe = @"A:\Users\Tono\Desktop\ConsoleApplication1.exe"; AppDomain myDomain = AppDomain.CreateDomain("MyDomain"); Assembly a = Assembly.Load(System.IO.File.ReadAllBytes(pathToExe)); myDomain.Load(a.FullName); // Crashes here! } I have also tried: myDomain.Load(File.ReadAllBytes(pathToExe)); how can I add an assembly to the appdomain. Once

Assembly binding redirect does not work

余生颓废 提交于 2019-12-28 04:00:48
问题 I'm trying to set up an assembly binding redirect, using the following app.config: <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.AnalysisServices" PublicKeyToken="89845dcd8080cc91" /> <bindingRedirect oldVersion="10.0.0.0" newVersion="9.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> I'm running the program on a machine with version 9.0.242.0 in the GAC, with the

Release .dll and .pdb after loading .dll file dynamically

浪尽此生 提交于 2019-12-25 17:56:39
问题 I'm building a windows application where I can call coded UI project (project named RecordAndPlayback) by clicking on a button. My aim is to call the test methods in the coded UI project and then be able to modify the test then call it back from my win app without closing it using the same button. I managed to call the test method, but I have a problem in modifying the test method after that. Whenever I build my coded UI project, I get an error ERROR CSC(0,0): Unexpected error creating debug