473,657 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Win32, .Net, & COM Interoperabilit y

1 New Member
Dear All,
I am trying to write a C# DLL that would work with VBA (in VBA I can directly call C# dll) and relatively old Win32 application (ArcView3.x). For Win32 application I would like to use C++ Dll wrapper. It is possible to call Win32 Dlls from there. I created small test Dlls (see below). It works fine under Win 2000 but under XP Win32 application crashes without any messages while reaching CoCreateInstanc e(…) (see C++ code below).
Do I need to add something to C# dll code (some attributes like [ComVisible(true )])?

Below are steps I performed:

1) C# Dll code:

namespace Cs_CLR_DLL
{
public class Class1 : IClass1
public Class1() { }

public int OpenForm1()
{
// Form1 f1 = new Form1();
// f1.ShowDialog() ;

return 1;
}

public interface IClass1
{
int OpenForm1();
}
}

AssemblyInfo.cs :

[assembly: ComVisible(true )]
// [assembly: Guid("32fa638b-e5fd-4ab0-aa5f-f34d0cfc4913")]


Register for COM interop check box (in Properties) is checked


2) register C# dll with regasm:
regasm MyC#Dll.dll /t MyC#Dll.tlb



3) MFC VC++ Dll code:

#include "atlbase.h"
#import "Cs_CLR_DLL.tlb " no_namespace


extern "C" __declspec(dlle xport)
int CallFromAV1(){
AFX_MANAGE_STAT E(AfxGetStaticM oduleState());

HRESULT resH;
resH = CoInitialize(NU LL); //initialising COM
assert( SUCCEEDED(resH) );

CComPtr<IClass1 > m_pClient;

resH = CoCreateInstanc e(_uuidof(Class 1),NULL, CLSCTX_SERVER,
_uuidof(IClass1 ), (void**)&m_pCli ent);
assert( SUCCEEDED(resH) );

resH = m_pClient->OpenForm1();
assert( SUCCEEDED(resH) );

return resH;
}

Thank you very much in advance
Oleg
Jun 14 '07 #1
0 1240

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4020
by: Eitan | last post by:
Hello, I am using Visual Studio.net 2003. I am trying to find how to create Win32 DLL & Win32 Static Library. When going through the wizard it does not show me the option for these two project types. Any Idea? Eitan
3
7650
by: Dean L. Howen | last post by:
Could anyone tell me how to program win32 in C#?
1
567
by: CharlesHenri | last post by:
Hello, i plan to use a managed dll containing WinForm classes in an unmanaged win32 exe. Starting from NOTHING, how do i have to proceed ? I have found the following tutorial on microsoft.com : "Converting Managed Extensions for C++ Projects from Pure Intermediate
3
5326
by: Demetri | last post by:
Hello, My company has charged me with creating a web service that will validate a user and return the user's roles via Active Directory. The requirement is that the web service must return data to any consumer. This means the consumer may be a Java app or any app on any platform. Now, my knowledge of returning data to consumers who are not .Net applications or platforms is limited. I was told to make sure that SOAP
0
6734
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, SPECTRAMIND SOLUTIONS now announces a new batch of Prep Courses for CSQA & CSTE& ISEB & ISTQB & Business Analyst & SOA so as to prepare you thoroughly for the most prestigious certification exams conducted by International organizations. We...
0
2438
by: jbenezech | last post by:
Hi all , I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform some action. The java call looks like this: Win32::SetChildShowWindow(0); Win32::Process::Create(
0
1594
by: newbie73 | last post by:
Going through the tutorial on http://swig.org, I created the example files (pasted below). After generating the _wrap file, I tried compiling (using mingw32) and received a lot of undefined reference compiler errors: ...\build\temp.win32-2.5\Release\example_wrap.o:example_wrap.c:(.text+0x670f): undefined reference to `_imp__PyExc_MemoryError' there are many other similar errors all prefaced with _imp__Py, so I am assuming there is a...
1
1449
by: =?Utf-8?B?U3dhcG5pbA==?= | last post by:
I have C++ application with some functionality C# application with some functionality. I want to use some functions from C++ application in C# application or vicversa, then how can i do using interoperability. I want both way interoperability procedure (steps) to achieve that.
1
269
by: Rami | last post by:
I use Winforms and win32 dll with interoperability. I want to port to WMF. Can I use and how the dll from my WPF application? Regards Rami
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.