COM Exception 8001010d

A

Anders Eriksson

I'm using WM_COPYDATA to send a string from one program to an other.
In the receiving program I have to override WndProc, see code below. In
WndProc I need to call a button_click function that does a call on a COM
server.

This results in a COMException: 8001010d, See below for full exception.

According to some threads I have found using Google, the problem is that
WndProc is using COM and therefore I can't call a COM server from WndProc.

Anyone that has an idea on how to solve this?

// Anders

Exception:

System.Runtime.InteropServices.COMException was unhandled
Message="Hämtningen av COM-klassfabriken för komponenten med CLSID
{14660C3E-3CF7-4CA5-9B32-913F3DD6F19F} misslyckades på grund av följande
fel: 8001010d."
Source="DCMarkerLib"
ErrorCode=-2147417843
StackTrace:
vid DCMarkerLib.LEngine.CreateDocument(Dictionary`2 dict,
DocsType type) i C:\Users\ame\Documents\Visual Studio
2008\Projects\SandvikCoromant\DCMarker\DCMarkerLib\LEngine.cs:rad 460
vid DCMarkerLib.LEngine.CreateImage(Dictionary`2 dict, String
id) i C:\Users\ame\Documents\Visual Studio
2008\Projects\SandvikCoromant\DCMarker\DCMarkerLib\LEngine.cs:rad 854
vid DCMarkerLib.Job.CreateImage(Dictionary`2 dict, Int32 block)
i C:\Users\ame\Documents\Visual Studio
2008\Projects\SandvikCoromant\DCMarker\DCMarkerLib\Job.cs:rad 259
vid DCMarkerLib.Job.Parse() i C:\Users\ame\Documents\Visual
Studio 2008\Projects\SandvikCoromant\DCMarker\DCMarkerLib\Job.cs:rad 133
vid DCMarker.Form1.button1_Click(Object sender, EventArgs e) i
C:\Users\ame\Documents\Visual Studio
2008\Projects\SandvikCoromant\DCMarker\DCMarker\Form1.cs:rad 91
vid System.Windows.Forms.Control.OnClick(EventArgs e)
vid System.Windows.Forms.Button.OnClick(EventArgs e)
vid System.Windows.Forms.Button.PerformClick()
vid DCMarker.Form1.loadBtnfnc() i C:\Users\ame\Documents\Visual
Studio 2008\Projects\SandvikCoromant\DCMarker\DCMarker\Form1.cs:rad 39
vid DCMarker.Form1.WndProc(Message& m) i
C:\Users\ame\Documents\Visual Studio
2008\Projects\SandvikCoromant\DCMarker\DCMarker\Form1.cs:rad 55
vid
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
vid
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
vid System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
vid System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG&
msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
vid
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
vid
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
vid
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
vid System.Windows.Forms.Application.Run(Form mainForm)
vid DCMarker.Program.Main() i C:\Users\ame\Documents\Visual
Studio 2008\Projects\SandvikCoromant\DCMarker\DCMarker\Program.cs:rad 32
vid System.AppDomain._nExecuteAssembly(Assembly assembly,
String[] args)
vid System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
vid
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
vid System.Threading.ThreadHelper.ThreadStart_Context(Object state)
vid System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
vid System.Threading.ThreadHelper.ThreadStart()
InnerException:


CODE:
private delegate void loadBtn();

private void loadBtnfnc()
{
button1.PerformClick();
}

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_COPYDATA:
Win32.CopyDataStruct CD =
(Win32.CopyDataStruct)m.GetLParam(typeof(Win32.CopyDataStruct));
string strData =
System.Runtime.InteropServices.Marshal.PtrToStringAuto(CD.lpData);

textBox1.Text = strData;
textBox1.Refresh();

// load job file
loadBtn x = loadBtnfnc;
x();
break;

default:
// let the base class deal with it
base.WndProc(ref m);
break;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top