Do assemblies have an initialization and / or completion routine?

I am trying to find an error in my application; unhandled exception. It seems that the exception is somewhere somewhere independent of my code. The only explanation I can find is that the assembly I'm using is executing some code that throws an exception.

So, do the assemblies have an initialization and / or completion procedure, or something similar?

+3
source share
5 answers
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
  bei Unify.SQLBase.Data.SQLBaseCommand.Dispose
  bei Unify.SQLBase.Data.SQLBaseCommand.Finalize

Yes, this is a very unpleasant exception. It is raised by the finalizer of the SQLBaseCommand class. What happens when the finalizer thread is started. It is completely asynchronous from your code, it can hit at any given time. The CLR will immediately terminate your program.

, SQLBase . , . , SqlCommand, . , (Unify).

+2

appdomain:

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    throw new NotImplementedException();
}

, - , . , "" → "" "" . , .

+3

, .NET

+1

, # , CLR v2. IL. . http://blogs.msdn.com/b/junfeng/archive/2005/11/19/494914.aspx.

, . , SQLBaseCommand.Dispose . , :

  • SQLBaseCommand , IDisposable? , , , SQLBaseCommand , , ( ).
  • SQLBaseCommand. API? ?
  • , Reflector Red Gate (http://www.red-gate.com/products/dotnet-development/reflector/), SQLBaseCommand #. Finalize Dispose. , , - ?
+1

( ), safegaurds .

, MQ . , , , , . " ".

A better way would be to create a singleton class that manages relationships with MQ. Singleton is created once in your class constructor. It will have to provide an explicit "registration" method, and any other methods that access MQ will be part of this singleton and may use the register method implicitly. The advantage here is that every time you call MQ, the system checks that MQ is registered, and if it does not register it before making a call.

0
source

Source: https://habr.com/ru/post/1789464/