assemblies

.NET Load assemblies at runtime Again

I posted a similar question a time ago. I need to load an assembly at runtime. This is easy if I know the absolute path of the dll at runtime. But I dont :( The assembly.Load() or LoadFromFile() fails if the file is not in the application root. The only thing I have is the dll name. The dll could be located in the root, system32 or in...

Create Instance from assembly and its dependencies in C#

I have an app (let's just call it MyApp) that dynamically creates source code for a class and then compiles it. When it compiles the source code I also reference another DLL (that is the base class for this newly created class) that already exists in another folder. I do the following to compile and output the DLL: //Create a C# code pr...

How to expose only one particular class from an assembly?

Suppose assembly Assembly1.dll contains 3 classes: Class C1, C2, C3. I want to expose only class C1 to the outside world. Classes C2 and C3 will not be accessible. How to acheive this? Note: Making classes C2 and C3 private is not an option as this will make them unaccessible inside the assembly itself. ...

Serialize in memory object with C#

I've got a program that picks up some code from script files and compiles it. And It works fine. The problem is: in the scripts I declare a couple of classes and I want to serialize them. Obviously the C# serializer (xml and binary) doesn't like to serialize and the de-serialize object defined in a in-memory assembly. I prefer to don't...

Which type of key .NET assemblies uses for signing and how to create it?

I have read many MSDN articles about assembly signing and I haven't found nothing about creating the key, just about creating the file, but the 3 methods listed to create a file needs a pre-generated key. Can you provide me a link to a tutorial to this? ...

List all available .NET assemblies

What is the best way to list all available .NET 2.0 assemblies? An example of the list needed is the one MS Visual Studio shows when you do 'Add Reference...' in the .NET tab. I have read Visual studio uses its own directory configuration and the GAC another and .NET instalation another. Any ideas of how I can know where this directori...

Error when creating assembly in SQL: MSG 33009

I'm attempting to load a dll into MSSQL with: USE dbname GO CREATE ASSEMBLY foo FROM 'C:\foo\foo.dll' WITH PERMISSION_SET = UNSAFE GO And I'm getting an error that states: Msg 33009, Level 16, State 2, Line 2 The database owner SID recorded in the master database differs from the database owner SID recorded in database 'dbname'. ...

Can I use a single BIN folder for several ASP.NET applications?

Keep in mind that I don't want to use the GAC since my assemblies are frequently updated and I do not wish to register them after each update. ...

.Net: Running code when assembly is loaded

Is it possible to run some code when an assembly is loaded, without doing anything specific in the loading code? What I am looking for is like a static constructor on a type. Eg: Assembly A does not know about Assembly B, but B does know about A. Assembly A needs to know certain things about B if B is loaded. When Assembly B is loaded ...

Visual Studio: How to reference assemblies in Visual Studio?

i have a debug and a release version of an assembly dll. They are sitting is directories on my computer. For other developers they are sitting in directories on their computer. For the debug version of the application i want to use the debug assembly. For the release version of the application i want to use the release assembly. That'...

What are the benefits of maintaining a “clean” list of assembly references?

Just like Carl's question over here I would like to ask you (because I couldn't find it out on my own :( ) if there is any benefit by removing an assembly reference that is not statically nor dynamically (via reflection for example) used. ...

StructureMap and scanning assemblies

So, I have a .NET solution that uses StructureMap, and I'd like to have StructureMap read an outside assembly that implements an interface from a project in that solution and defines the registry entry for it. StructreMap configuration for my solution: ObjectFactory.Initialize(registry => { registry.Scan(assembly => { assembl...

ASP.NET "Reference required to assembly" error.

I have an ASP.NET page A that uses a data layer assembly DAL. I reference the DAL assembly with a <%@ Assembly Name="NGC.DAL" %> tag since there is no project to add the reference to. The assembly itself I copied to the pages' bin folder. The assembly DAL is a project that references System and System.Data. Now when A calls a method in...

Loading Assemblies from a .Net Application in a 'Sandbox Environment'

I am currently developing an application in where a user will dynamically choose dlls and the application will execute some of the methods in that dll. (if you follow the first link, you will see that I am developing a sort of Robocode game application using the .Net Framework). For example, when the battle starts, the run method from ...

How to reference a namespace from a specific assembly?

So here is my problem. My (test) project references both Castle Windsor and Rhino Mocks. I am creating a class which implements Castle.Core.Interceptor.IInterceptor from the Castle.Core.dll assembly In building Rhino Mocks, Ayende used Castle.Core.Interceptor and includes the whole darn namespace inside the Rhino.Mocks.dll So when I...

How can I retrieve an embedded xml resource?

I added an XML file as an embedded resource in my class library by using the accessing the project properties in Visual Studio and then Resources | Add Resource | Add Existing File... I've tried to access the file using the following code, but I keep getting a null reference returned. Anyone have any ideas? var path = Server.MapPath("~...

Accessing a .NET Assembly from classic ASP

I have been trying to access a .NET Assembly that I have created in classic ASP using dim foo set foo = Server.CreateObject("TestAssembly.MyClass") The problem is I'm getting an error: Server object error 'ASP 0177 : 800401f3' Server.CreateObject Failed /test.asp, line 4 Invalid class string I have registered the assembly (TestA...

.NET assemblies spanning multiple files and unit testing

Can anyone point me to some information on .NET assemblies spanning multiple files? I've found this remark on MSDN (here): Although it's technically possible to create assemblies that span multiple files, you're not likely to use this technology in most situations. I'm asking because I have the business logic and the unit test...

How can I uninstall Win32 assemblies and cleanup WinSxS?

After a lot of trial and error (mostly due to lack of documentation and examples) I have managed to create MSI installers that install custom DLLs to WinSxS as side-by-side assembly. There is only one problem: Uninstalling leaves all files (DLLs, manifests and catalogs) in the WinSxS directory. How can or should I best clean that up? I k...

How to access Web.config from a referenced assembly?

I need to access a web application's web.config from a referenced assembly. I need to get the file's path or the configuration object. I can't do this using System.Reflection.Assembly.GetEntryAssembly as I do for the application's configuration of a windows exe. Thanks ...