COM Interop, the RPC server is not available in C #

I am using COM Interop, I am instantiating COM class objects from interop dll
Therefore, very few objects are successfully instantiated and make remote procedure calls without any problems, But sometimes it raises exceptions, such as RPC Server cannot be used.
The COM component I am using is written in VB, and I use it in c#.

So, anyone Can tell me the possible cause of the problem (RPC server is unavailable) and the method to solve this problem.

I am very helpless with this problem now.

So, if you can help me, Thanks

After reviewing my COM implementation method, I found this bug. I use The static class initializes the COM instance, and the initialization thing happens in the static constructor. Therefore, each application session must be initialized once. In this case, when the COM instance is destroyed or discarded, calling the COM method will trigger Exception (RPC Server is not available).
So, I use the following methods to overcome this problem

try
{
m_COMObject. SomeMethod();
}

Exception(exception exception)
{
DisposeCOMObject();
InitializeCOMOBject();
COMObject.Somethod ();
}


public void DisposeCOMObject()
{
m_COMObject = null;
var process = Process.GetProcessesByNames(" COM .exe").FirstDefault();

if(process != null)
{
process.kill();
}
}


public void InitializeCOMObject()
{
m_COMObject = null;
m_COMObject = new COMObject();
}

If the COM instance cannot be called, configure Instance and reinitialize COM and get the instance, then call RPC Server.

I am using COM Interop, I am instantiating COM class objects from interop dll
So, Few objects are successfully instantiated and make remote procedure calls without any problems, but sometimes exceptions are thrown, such as RPC Server cannot be used.
The COM component I am using is written in VB, and I use it in c# This component.

So, anyone can tell me the possible cause of the problem (RPC server is unavailable) and the way to solve this problem.

I am now about this problem Very helpless.

So, if you can help me, please thank you

After reviewing my COM implementation method, I found This bug. I use a static class to initialize the COM instance, the initialization thing happens in the static constructor. Therefore, each application session must be initialized once. In this case, when the COM instance is destroyed or discarded , Calling the COM method will cause an exception (RPC Server is not available).
So, I use the following methods to overcome this problem

try
{
m_COMObject.SomeMethod();
}

Exception(exception exception)
{
DisposeCOMObject();
InitializeCOMOBject();< br /> COMObject.Somethod();
}


public void DisposeCOMObject()
{
m_COMObject = null;
var process = Process.GetProcessesByNames("COM .exe").FirstDefault();

if(proce ss != null)
{
process.kill();
}
}


public void InitializeCOMObject()
{
m_COMObject = null;
m_COMObject = new COMObject();
}

If the instance of COM cannot be called, configure the instance and reinitialize COM and get Instance, then call RPC Server.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2461 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.