473,805 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC6 ATL DLL interop with VB.NET

I have an existing VC6 ATL COM DLL. It has a number of methods within it
that take a byte array as the methods parameters. Here's what the IDL looks
like in the VC6 DLL:

[id(32), helpstring("met hod GetSystemConfig ")] HRESULT GetSystemConfig ([in,
out] SAFEARRAY(unsig ned char) *pData, [out, retval] long *retval);

As you can see it is a byte array (SAFEARRAY)

In the VB.NET object browser the the prototype looks like this:

Public Function GetSystemConfig (ByRef pData as System.Array) as Integer

PROBLEM: Everyone of the API calls made in the following code section throws
an error:
"Specified array was not of the expected type. Err.Number = 5 "

I currently have VB.NET up in the VC 6 debugger just to see if the interface
ever gets called, and it does not. Which means my problem is in the interop
dll that Dot net creates automatically.

Public Function GetSystemConfig (ByRef pBytes As System.Array) As Integer
On Error GoTo processerror

Dim pByte() As Byte
GetSystemConfig = (ESITapi.GetSys temConfig(pByte ) = S_OK)

Dim pByt(512) As Byte
GetSystemConfig = (ESITapi.GetSys temConfig(pByt) = S_OK)

Dim chars As Byte() = System.Text.Enc oding.ASCII.Get Bytes("hello
world")
GetSystemConfig = (ESITapi.GetSys temConfig(chars ) = S_OK)

Dim arr As Array

GetSystemConfig = (ESITapi.GetSys temConfig(arr) = S_OK)

Dim strArr() As String = {"1", "2", "3"}
GetSystemConfig = (ESITapi.GetSys temConfig(strAr r) = S_OK)

Dim pB(512) As Char
GetSystemConfig = (ESITapi.GetSys temConfig(pB) = S_OK)

End Function

Is there any way I can debug VB.NETS interop DLL ?
Any idea's what's wrong with the parameters I'm passing ?
FYI, I'm using VS 2005
This ATL control was written for use with VB6 and has been in production for
years, I'm trying to reuse it in the Dot Net world.
Anyone got any ideas ?

Dave
Apr 12 '06 #1
5 2939
Hi Dave,

From you description, I understand that you want to call ATL COM DLL in
VB.NET. The COM DLL has been working with VB6 well.
If I misunderstood, please feel free to let me know.

I think so far can you provide the some code about what will you do in the
method
[id(32), helpstring("met hod GetSystemConfig ")] HRESULT GetSystemConfig ([in,
out] SAFEARRAY(unsig ned char) *pData, [out, retval] long *retval);

Also We have a wizard to upgrade VB6 application to VB.NET, I think you may
try to use that Wizard to upgrade VB6 program to VB.NET to see if that
works.

Please NOTE that may need some tweak after convertion.

You may have a try and let me know the result.

If you still have any concern, please feel free to let me know.
I look forward to hearing from you.

Best regards,

Peter Huang

Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 13 '06 #2
Peter,

I actually figured this problem out. It took me all day but I determined
that the SafeArray type that I assigned it in the code and the type that I
assigned to it in the IDL were different. This didn't cause any problems in
VB6 but in VB.NET and C# when used with the .Net interop dll it is a
problem.

I'm not using VB6, I'm using VB.NET, there is no problems using the DLL with
VB6 that's what it was initially used for. VB.NET and C# have problems with
this dll.

On another note, is there a way to debug the interop DLL ? Like generate a
project for it for debugging purposes ?

Here's what needs to be known by anyone that trys to do interop with an ATL
COM control with SafeArrays as parameters in methods. This code sample was
cut and pasted in but should provide a decent example.

[id(32), helpstring("met hod GetSystemConfig ")] HRESULT GetSystemConfig ([in,
out] SAFEARRAY(unsig ned char) *pData, [out, retval] long *retval);

STDMETHODIMP CATLTapi::GetSy stemConfig(SAFE ARRAY **pData, long *retval)
{
SAFEARRAY* pAr = NULL;
SAFEARRAYBOUND rgsArrayBound[1];

rgsArrayBound[0].Lbound = 0;
rgsArrayBound[0].cElements = 50; // Array length
pAr = SafeArrayCreate (VT_UI1,1,rgsAr rayBound);

// Pointer to the pAr's data section
LPVOID pV;
HRESULT RES;
RES = SafeArrayAccess Data(pAr,&pV);

if(RES)
{
LogIt("OnDevSpe cific() SafeArrayAccess Data Error!");
break;
}
memcpy(pV,"1234 567890123456789 012345678901234 567890123456789 0",50);

SafeArrayUnacce ssData(pAr);

*pData = pAr;
.....
Dave

""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:CZ******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Dave,

From you description, I understand that you want to call ATL COM DLL in
VB.NET. The COM DLL has been working with VB6 well.
If I misunderstood, please feel free to let me know.

I think so far can you provide the some code about what will you do in the
method
[id(32), helpstring("met hod GetSystemConfig ")] HRESULT GetSystemConfig ([in, out] SAFEARRAY(unsig ned char) *pData, [out, retval] long *retval);

Also We have a wizard to upgrade VB6 application to VB.NET, I think you may try to use that Wizard to upgrade VB6 program to VB.NET to see if that
works.

Please NOTE that may need some tweak after convertion.

You may have a try and let me know the result.

If you still have any concern, please feel free to let me know.
I look forward to hearing from you.

Best regards,

Peter Huang

Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 13 '06 #3
Hi Dave,

From your description, you have resolved the issue, if I have any
misunderstandin g please feel free to post here.
I know that your solution worked in VB6, because we can upgrade VB6 Project
into VB.NET project, so I suggest you have a try.

To debug an application, we need the symbols otherwisse we will only see if
the assembly code. Unfortunately , the IDE generated Interop Assembly
neither generated Symbols(commonl y it is pdb file) nor source code. So we
can not debug into it.
But if you have both .NET client source code and C++ source code, we can
debug into the C++ code when we try to call into C++ aproach from .NET.
Best regards,

Peter Huang

Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 14 '06 #4
I have already upgraded the VB6 project to VB.NET, but I still use it as a
reference point.

I know how to debug the C++ code, I actually launch VS 2005 from the VS 6
debugger.

It's too bad the interop can't be debugged seems like there could be some
value in that.
""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:mQ******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Dave,

From your description, you have resolved the issue, if I have any
misunderstandin g please feel free to post here.
I know that your solution worked in VB6, because we can upgrade VB6 Project into VB.NET project, so I suggest you have a try.

To debug an application, we need the symbols otherwisse we will only see if the assembly code. Unfortunately , the IDE generated Interop Assembly
neither generated Symbols(commonl y it is pdb file) nor source code. So we
can not debug into it.
But if you have both .NET client source code and C++ source code, we can
debug into the C++ code when we try to call into C++ aproach from .NET.
Best regards,

Peter Huang

Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 14 '06 #5
Hi Dave,

As I said before, the IDE did not generate Symbol file and source file for
the Interop Assembly so the any debugger did not know that the code is.
If you do need to behavior, you have to create the Interop Assembly
manually so that it is a common class library coded by yourself.
How to: Create Wrappers Manually
http://msdn2.microsoft.com/en-us/lib...00(VS.80).aspx

But we may still need the symbols for the CLR itself.

Commonly the IDE will generate correct Wrap assembly for us, if you did not
want the generated Assembly, we have to create one ourselves per the link
above.

Anyway, there is a detailed COM Interop Referece Book, you may have a check.
..NET and COM: The Complete Interoperabilit y Guide (Paperback)
by Adam Nathan
http://www.amazon.com/gp/product/067...3?v=glance&n=2
83155

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang

Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2364
by: roy | last post by:
I try to call com written in VB 6.0. When I use VS.net Studio to do the debuging, some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation' Application. ----------------------------------------------------------- --------------------- Configuration Error Description: An error occurred during the processing of a
0
1570
by: roy | last post by:
I try to call com written in VB 6.0., some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation' Application. ----------------------------------------------------------- --------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request.
0
2294
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net about the global assembly cache (GAC) and primary interop assemblies (PIA) and so forth, and did all the recommendations, in terms of tweeking Office, installing the .NET Office stuff for framework 1.1, etc. I got it to the point where it compiles ok,...
0
2794
by: lacour | last post by:
I can't seem to figure out the difference between adding a COM dll reference in VS2003 and by using TLBIMP. I have a COM dll that references another COM dll, and I want the syntax of my interop-filenames to be interop.<NameOfCOMDLL>.dll I now make the first interop file tlbimp COM1.dll /out:interop.COM1.dll /namespace:COM1
1
1999
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system: API Consumer ( Native C++/C# ) || ******************************************* * ...
8
3427
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be added. Converting the type library to a .Net assembly failed. A depended type library 'CDO' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added." ...
7
10967
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed this screen below. Please help, thanks in advance... Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify...
2
7307
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a "Array index out of bounds". Microsoft.Office.Interop.Outlook._Application olApp = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
1
2872
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox and server (Exchange server mail box) to connect and then save the mailitems(from Inbox or any other folder) based on a filter to a*.msg file. I want to achieve this using only one Interop dll if this is possible. Tried so far:
0
2060
by: Tina | last post by:
I've gotten this before where it says there is a problem with Interop.MSDASC but I can't remember what causes this. This is a 1.1 app I'm trying to debug in vs2005. It was running yesterday just fine. Help! T Server Error in '/VT.Users' Application. -------------------------------------------------------------------------------- Configuration Error
0
9718
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
9596
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,...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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
9186
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...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.