Discussion:
COR_E_TYPELOAD error with CoCreateInstance of a COM exposed .Net class
(too old to reply)
a
2012-05-03 14:11:28 UTC
Permalink
Raw Message
I'm using SXS COM activation to use CoCreateInstance to create a COM
exposed .Net class --- I get
CoCreateInstance failed; HRESULT: 0X80131522
Why might this be? --- I can't think how to debug this.

Thanks in advance for any advice on debugging this issue.
a
2012-05-04 08:29:12 UTC
Permalink
Raw Message
I'm using SXS COM activation to use CoCreateInstance to create a  COM
exposed .Net class --- I get
CoCreateInstance failed; HRESULT: 0X80131522
Why might this be? --- I can't think how to debug this.
Thanks in advance for any advice on debugging this issue.
Found the problem, recording here for posterity.

So, I got no help from sxstrace or fuslogvw.

The problem was this:

I was writing a simple C# class like this:

UiLauncher.cs
==========

[ComVisible(true)]
[Guid("9014512b-748e-4752-8bab-ad340f947df3")]
[ClassInterface(ClassInterfaceType.None)]
public class UiLauncher : IUiLauncher
{
private ExampleUi m_ui = null;

private IwpmExampleViewModel m_example_vm = null;

[DllImport("User32.dll")]
static extern IntPtr SetParent (IntPtr hWnd, IntPtr hParent);

public long Show(long parent, IwpmExampleViewModel vm)
{
Debug.Assert(0 != parent, "parent is 0");
Debug.Assert(null != vm, "vm is 0");

m_example_vm = vm;
m_ui = new ExampleUi(vm);
m_ui.Show();

WindowInteropHelper wih = new WindowInteropHelper(m_ui);
IntPtr hWnd = wih.Handle;
IntPtr ipparent = new IntPtr(parent);
SetParent(hWnd, ipparent);
return (long)hWnd;
}
}


Note --- there is no namespace.


I hacked together (by copy / paste and change from some other example)
a manifest file to allow SXS that looked like this:


manifest
======



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
name="wpfuiserver"
version="0.0.0.0"
processorArchitecture="MSIL" />
<clrClass
clsid="{9014512b-748e-4752-8bab-ad340f947df3}"
threadingModel="Both"
name="wpfuiserver.UiLauncher"
runtimeVersion="v4.0.30319">
</clrClass>
<file name="wpfuiserver.dll">
</file>
</assembly>


Basically I got the clrClass attribute name wrong --- I had put in a
bogus namespace where none was needed so instead of
name="wpfuiserver.UiLauncher"

I should have just had

name="UiLauncher"

Loading...