Problem creating C# interop wrapper manually

dotnet framework


  • 1. Creating .Net to .Net automation
    I have successfully written C# .Net applications that automate excel and word. Now I need to implement automation between .Net applications and I am thoroughly confused. Interop refers to COM - .NET interoperability, is it applicable? In my fiddling I have tried to link to my running .NET apps only to spawn new instances. I want to link to the current running instance and automate it just I do with Word and Excel. Can someone point me in the right direction?
  • 2. OLE server
    Is it possible to write ole server application using .NET? Application should be in-place activated. So far, I found only MFC samples for ole automation servers. Thanx
  • 3. Accessing com-object with same name and versions but different functionallity?
    Hi! I writing a app which communicate with Adobe InDesign through a com-interface. Adobe has released a new version of InDesign called InDesign CS and a new com-component accessing it. In my app I have some different project, one talking to InDesign CS and another one talking to the older version InDesign 2.0. The referenced com-components have the same name "InDesign" and the same version "1.0". (I.e: InDesign 2.0 Type Library Version 1.0 and InDesign CS Type Library Version 1.0). I am using No-Touch Deployment and when the app is started Interop.Indesign.dll is downloaded. The problem is that the app is using the same interop dll for both projects, (i.e it uses the interop that is first accessed). How can I make the app know the difference between the com? Can i rename them or something? Best Regards / Steve

Problem creating C# interop wrapper manually

Postby Erika Schaab » Wed, 07 Jun 2006 05:15:27 GMT

When I try to follow the How to: Create Wrappers Manually ( 
 http://www.**--****.com/ ) with my own COM 
object, I always get a System.ExecutionEngineException when I try to call 
methods on the COM class from C#.

Can anyone tell me what I'm doing wrong?

Here's my IDL/C# wrapper code:

import "oaidl.idl";
import "ocidl.idl";
helpstring("ITestClass Interface"),
interface ITestClass : IDispatch{
[id(1), helpstring("method DisplayName")] HRESULT DisplayName(void);
helpstring("TestInterop 1.0 Type Library")
library TestInteropLib
helpstring("TestClass Class")
coclass TestClass
[default] interface ITestClass;

C# Wrapper Code

// Assembly Interop.TestInteropLib, Version

[assembly: AssemblyVersion("")]
[assembly: ImportedFromTypeLib("TestInteropLib")]
[assembly: Guid("f6243c43-3c58-4bdc-91cc-cdf5b035c5ab")]
namespace TestInteropLib
      [ComImport, Guid("00DE6014-269A-4F3F-954B-656F3579501F"), 
      public interface ITestClass
MethodCodeType=MethodCodeType.Runtime), DispId(1)]
            void DisplayName();

      [ComImport, CoClass(typeof(TestClassClass)), 
      public interface TestClass : ITestClass

      [ComImport, Guid("DEA53701-4664-4558-AFE1-CCC1F24A9D86"), 
TypeLibType(2), ClassInterface(0)]
      public class TestClassClass : ITestClass, TestClass
            // Methods
MethodCodeType=MethodCodeType.Runtime), DispId(1)]
            public virtual extern void DisplayName();

Similar Threads:

1.Creating Com Interop Wrapper Manually

2.Problems creating COM wrapper for C# dll (regasm.exe)

I called regasm.exe /tlb CameraManagement.dll and I got

When I look inside with OleView.exe or create C++ header  I see
something like that:

struct __declspec(uuid("37944845-f74f-3999-b972-d42355a78bcd"))
_AlarmSetting : IDispatch

struct __declspec(uuid("5e6abb0e-b170-377d-9902-20bb5388a53c"))
_AlarmSetting2 : IDispatch

struct __declspec(uuid("8969367c-f590-333c-994e-c0b2a37ce928"))
_Camera : IDispatch

they're just empty interfaces, only enums are exported correctly - but
oryginal C# classes have plenty of methods ! Where have they gone ? Am
I missing something ?

Thanks in advance

3.creating a C# object from ASPv3 using Interop - problem


I'm encountering a problem while trying to create a C# 
object from ASP v3.

The C# class is derived from ServicedComponent, has a 
strong name key and is registered into the GAC using 
regsvcs.exe .

ASP is running under the SYSTEM account, and that account 
has full control permissions to the folder where my C# 
assembly file is located.

The error message I am receiving is:

Server.CreateObject failed while checking permission. 
Access is denied to this object.

Any help would be appreciated!



4.Problems manually creating a CHeaderCtrl in a custom control (derived from CWnd)

Hi, i'm trying to write a custom ListCtrl syle control with an integrated
CHeaderCtrl but i'm running into some initialisation problems.  My control
is derived from CWnd like this:

class CScrollCtrl : public CWnd
    CHeaderCtrl    m_HeaderCtrl;

then i initialise the header-control like this:

    m_HeaderCtrl.Create(...., this, .....);

I'm testing this control in a dialog-based test application with one
instance created by placing a custom-control in the MFC dialog editor and
everything was going fine until I tried to create a second instance by
"manually" adding a CScrollCtrl member variable to the parent dialog and
calling the CScrollCtrl::Create() method from the OnInitDialog() method of
the parent dialog.

When i try to create the second instance MFC throws an ASSERT on some code
trying to "attach" something to something else (or something =) I've looked
around for some sample code but I haven't found anything where someone is
actually creating their own CHeaderCtrl instance in a custom control it's
all just subclassing examples so far.

Any Ideas?


5.Problem creating "manually" a MDI with its view

Hi all...

I programmed an MDI application using document-view architecture. All works
fine when I add the frame, the view and the document using CMultiDocTemplate
in InitInstance method.

One of the functionalities the program has is the search for certain
information. Since the search is only  for displaying data without the
functionality to save the document, I tried to create the MDI frame and view
without the corresponding document.

This is the code:

void CMainFrame::OnBizFind()
 CBusquedaDlg dlg;
 dlg.SetDatabase(((CGamaApp *)AfxGetApp())->GetDatabase());
 if( dlg.DoModal() == IDOK )
  CRuntimeClass* pFrameClass = RUNTIME_CLASS(CBusquedaFrame);
  CMDIChildWnd *pWnd = (CMDIChildWnd *)pFrameClass->CreateObject();

  if( pWnd )
   CCreateContext ctx;
   ctx.m_pCurrentDoc = NULL;
   ctx.m_pCurrentFrame = NULL;
   ctx.m_pLastView = NULL;
   ctx.m_pNewDocTemplate = NULL;
   ctx.m_pNewViewClass = RUNTIME_CLASS(CBusquedaView);

   CString sTitle;
   sTitle.Format(_T("Resultados de bqueda - %s"),
COleDateTime::GetCurrentTime().Format(_T("%d/%m/%Y %H:%M:%S")));
   pWnd->Create(NULL, sTitle,
       this, &ctx);
   dlg.Populate((CBusquedaView *)pWnd->GetActiveView());

CBusquedaDlg is a modal dialog to ask for the filter to the search.
CBusquedaFrame and CBusquedaView (derived from CView) are the frame and the
view, respectively.

That works, but sometimes an extrange behaviour occurs. The "x" at the top
right corner of the frame, and the minimize and maximize buttons disappear,
not allowing to maximize, minimize or close the frame. What may be

Can I use CMultiDocTemplate without specifying a document so that all that
management is done automatically by the MFC framework? Maybe the code I'm
suing to create the frame is incorrect or I missed something

Thanks in advance

6. Problems registering C# COM object manually

7. Creating an unmanaged wrapper to C# Library

8. Creating aspx.cs file manually

Return to dotnet framework


Who is online

Users browsing this forum: No registered users and 43 guest