.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Can an assembly get notified after it has been loaded?

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :.NET Framework

I need to do some stuff when an assembly is loaded.  I would like to put that code into the assembly itself.

Is there a particular delegate that the AppDomain will call on an assembly to notify it that it's been loaded?  How can an assembly make it known to the CLR that it wants to be notified of its loading?

Note that this is different than some other AssemblyLoadEventHandler delegate that is registered via the AssemblyLoad event -- I want the assembly being loaded to be notified that it has been loaded.



View Complete Post

More Related Resource Links

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in t

First, yes I've read every article I can find including this one: http://msmvps.com/blogs/rfennell/archive/2010/03/27/mixed-mode-assembly-is-built-against-version-v2-0-50727-error-using-net-4-development-web-server.aspx Of course it's for web server stuff, but I found this in my config file and added it. However, my problem now is that if I build in release mode I get a hard error in the error list telling me the same thing, even though it runs fine in debug and has the information in my app.config file. The really anoying part is that the error doesn't tell you WHICH assembly is the offending one. Anyone have any ideas?

The Assembly was created in Runtime v1.1.4322 and cannot be loaded while runtime 4.0 without additio

Hello! Note: The text above was translated into English. I experience this problem when adding DirectX references and usings to a Form in Visual Studio 10 Professional, Trial Version. The dlls (Microsoft.DirectX; Microsoft.DirectX.Direct3D) are included from X:\Windows\Microsoft.Net\DirectX for Managed Code\1.0.2902.0\. I really like to begin coding DirectX. Do you know what this Message means? What shall I do?   Many thanks, Regards

Could not load file or assembly '0 bytes loaded from System, Version=, Culture=neutral, Publ

Hi I have a clickonce deployed application in my machine. When I tried to load the application, 90% of the application window is getting loaded but finally, I get the following error: Could not load file or assembly '0 bytes loaded from System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format. I have read somewhere that this error could be caused when something goes wrong with the .net framework in the machine. My machine is having .Net framework 2.0, 3.0 and 3.5. So which framework should I reinstall? The application is developed using .net 2.0. Also, please let me know how the application is partially loading(90%) if the framework is corrupted.? Regards Anoop.

How to debug a dynamically loaded assembly.

I have a system that locates and load assemblies at runtime.

It instantiates classes and invokes methods in them (they conform to an interface) but, even though I have opened the src file I cant set a breakpoint.

The debugger notes that "no symbols have been loaded for this document".

Is there a way to have the loaded assembly automnatically find/load debug symbols, or must I manually navigate and try to load the pdb file??


this assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded



He estado buscando mucho y ya no se que hacer con este error. Tengo reporting services 2008, .net framework 4 y trabajo con report builder 2.

Todos los reportes los puedo publicar correctamente en el report server, pero cuando voy a publicar el que tiene referencia a una dll propia obtengo este error: this assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded (rsErrorLoadingCodeModule).

Ya reinstale el framework 4, la dll ya se encuentra en la carpeta bin de report server y ya esta registrada usando la herramienta gacutil.exe.

Mi propia dll esta hecha bajo .net framework4.

Este montaje lo tengo en un servidor y funciona correctamente, pero el problema se me presenta a subir esto es un servidor propio de un cliente.

Agradezco la colabroración que me puedan prestar.

PD. me disculpan si lo publique en el sitio que no era... pero no supe a que otra categoría asociarlo.

[Business Logic Handler debugging] - The assembly is not loaded by inetinfo.exe process


Hi there,

Here is my story - my merge replication topology consists of one publisher (sql server 2008), a distributor (same server as publisher) and a subscriber (sql server 3.5 CE). I use web synchronization for my merger replication. Publisher, Distributor, Subscriber and IIS run all on the same (development) machine. I use MSSMS to synchronize the subscriber.

I've created a custom resolver (Business Logic Handler) that should perform some data modification that has been inserted at the subscriber, before it is merged into the publisher. It should but it doesn't so I need to debug it to see what's going on. I've followed steps form here http://msdn.microsoft.com/en-us/library/ms365150.aspx on how to debug a business logic handler on a Web server using Web synchronization and I'm stuck at step 7. MY PROBLEM IS when I attache to inetinfo.exe process from VS2008, I don't see my assembly to be loaded neither in Output nor in Modules window and the break points say that they will not be hit because the symbols were not loaded.

I configured web synchronization almost exactly as it says here http://msdn.microsoft.com/en-us/library/ms151810.aspx , the only difference is that I didn't configured and

Error: Encountered multiple versions of the same assembly with GUID...try pre-importing...TlbImp


Hi!  Can someone tell me how I can troubleshoot the following error: "Encountered multiple versions of the same assembly with GUID...try pre-importing one of these assemblies".

The website developed in VS 2010 (.Net 3.5). This error is only received on my workstation.  Another person developing the site does not experience this issue at all.  Also, not sure if this matters, but on my workstation the 'Assembly Information...' dialog contains no values even though the 'AssemblyInfo.vb' file does specify values for the title, desc, etc.  The GUID being referenced in the error is the main project of the three projects within the solution.

I tried looking through the GAC, but do not see any references to the projects or DLLs in the VS solution and am not sure what else/where to look.

If I delete the copy of the solution on my local machine and pull down a copy from source control (AnkhSVN) the solution will build with no error.  Once I make any changes, such as adding a new aspx file, then the error is received.

I can provide any additional information needed.

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


MySql.Data assembly problem



I added refernece MySql.Data to my project. My web.config looks like that:

<?xml version="1.0"?>
                <add assembly="MySql.Data, Version=, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

But when in ServerExplorer I try "Add Connection..." I can't find "MySql Database" in the "Choose Data Source" dialog box?

What the problem can be?

Registering controls of current assembly object reference NOT set error


Hi There,

I have created a simple ASP.net Web Application (2.0) and have added a web user control.

Now in my page I have added this control but I have registered like this,

<%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

Which means I want to access all the controls in my current Web Application project

Then I have added my user control like this,

<Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

Note that My Control has,

1) Public property PublicProperty as String

2) 1 Label control

In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).

I don't want to register my control using Src, TagPrefix etc. Any ideas?


An endpoint configuration section for contract 'xxx' could not be loaded because more than one end



I'm trying to test calling a webservice, I've found several free ones on http://webserviceshare.com, but none of them work for me.  Some of them give example calling code in C# which I've translated to VB.NET, they're typically just two to four lines, I don't think I've translated them incorrectly.

On that I've tried is US Zip Validator.  I added a Service Reference to http://www.webservicemart.com/uszip.asmx?WSDL, called ZipService.

I then call it like so:

            Dim myZipService As ZipService.USZipSoapClient = New ZipService.USZipSoapClient()
            Dim myCity As String = myZipService.ValidateZip("27707")

I get the following error on the first line of code:

"An endpoint configuration section for contract 'ZipService.USZipSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."

A page with information on this web service (including C# source code) is at:


Could not load file or assembly - Web Deployment Project



I have the following projects in a solution :

- A Web Application

- A Class Library

- A Web Deployment project

The Web Application compiles and run fine when I don't go through the Web Deployment Project. However when I try to use that, I get the following error:

Error 1 An error occurred creating the configuration section handler for hibernate-configuration: Could not load file or assembly 'NHibernate' or one of its dependencies. The system cannot find the file specified. (F:\Folke\Folke.csproj_deploy\Release\web.config line 4) 1 1 Folke.csproj_deploy

"An error occurred creating the configuration section handler for hibernate-configuration: Could not load file or assembly 'NHibernate' or one of its dependencies. The system cannot find the file specified. (F:\Folke\Folke.csproj_deploy\Release\web.config line 4)"

This is the beginning of my Web.config:


CLR Inside Out: Migrating an APTCA Assembly to the .NET Framework 4


The CLR security model in the Microsoft .NET Framework 4 has undergone some substantial changes, including the adoption of "Level2" transparency, similar to the Silverlight security model. Mike Rousos provides an in-depth explanation of how that will likely impact authors of AllowPartiallyTrustedCallers (APTCA) libraries.

Mike Rousos

MSDN Magazine March 2010

Test Run: Determining .NET Assembly and Method References


Before you can test any software system effectively, you must understand the system under test. If the system includes the Microsoft® . NET Framework, understanding the system under test includes understanding its assembly and method dependencies.

James McCaffrey

MSDN Magazine March 2006

Flex Your Data: Teach Old Data New Tricks with the Fully Loaded Advances in ADO.NET 2.0


ADO.NET 2.0 will streamline your data access development efforts. Its new features let you work better with XML and SQL Server, and they offer lots of other improvements as well. This article takes a detailed look at some of the more interesting enhancements and focuses on performance and flexibility.

Julia Lerman

MSDN Magazine April 2005

How to process data AFTER page is completely loaded for the user?


I have some logging that has to be done, which are some database update or inserts.

However this logging is of no importance to the user, so I only want to process the data/logs after the page is completed for the user.
As of now, if I process the data while the page is loading, I go from 1.4 to 2.0 speed (server side time processing of code), which is quite a bit comparing it is of no use to the user.

So I want this code only executed after that the page is complete.

I've been checking out Ajax, async pages etc, but the problem is it still gets executed before the page is rendered to the client, which means the client will have to wait longer then it is not being processed.

I've been checking out Threadpool.queueBackgroundWorker, however if I get it correct, this will still be executed before the page is shown to the user, as it has to complete before the prerender.

Then I thought about creating a new thread, and do the processing there, which would not have my page waiting to complete the data/logging.
However when I have 100 or 200 users loading pages at the same time, then that would mean I would be creating 200 threads on those loads, which I doubt will be good for performance. So if I want to solve this, I would have to create my own threadpool and only assign for example a max of 40 threads to it which can pr

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend