473,503 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raise Error to VB application

I havean app written in vb6 that links to a vb6 DLL file. The app handles
errors raised by the DLL based on the error number (Err.Number). I would
now like to convert the DLL to c#. How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?

Thanks

Alan
Dec 19 '05 #1
3 2351
Alan,

What you want to do in this situation is create your own class derived
from Exception. Once you do that, you can set the HResult property to the
value that corresponds to the number returned from Err.Number.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alan Roberts" <al**@statistixl.co.uk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
I havean app written in vb6 that links to a vb6 DLL file. The app handles
errors raised by the DLL based on the error number (Err.Number). I would
now like to convert the DLL to c#. How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?

Thanks

Alan

Dec 19 '05 #2
Alan,
How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?


throw Marshal.GetExceptionForHR(yourErrorCode);

where yourErrorCode is a HRESULT error code. Some HRESULTs will be
mapped to built-in VB error numbers and others are used as is.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 19 '05 #3
Thanks guys, I will have a play with these.

Alan

"Alan Roberts" <al**@statistixl.co.uk> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
I havean app written in vb6 that links to a vb6 DLL file. The app handles
errors raised by the DLL based on the error number (Err.Number). I would
now like to convert the DLL to c#. How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?

Thanks

Alan

Dec 19 '05 #4

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

Similar topics

3
1826
by: James Stroud | last post by:
Hello All, Is this a bug? Why is this tuple getting unpacked by raise? Am I missing some subtle logic? Why does print not work the same way as raise? Both are statements. Why does raise need to...
3
1962
by: Dmitry | last post by:
Hi, I have defined interface for COM components which inludes an argument being filled with additional error info, if such occurs. If inside I raise COM Error, I populate that parameter. In COM...
2
5430
by: Bogdan Zamfir | last post by:
Hi, I have a problem with err.raise I write a class module, and I want to use this mechanism to indicate errors when user set wrong values to properties But it seems the error is never raised...
1
10493
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
2
5101
by: Mortimer Schnurd | last post by:
Hi, I've been dabbling with C# for a short time now but am ready to use it in extending/converting older VB6 applications. I have one VB6 application I am now working to extend and I would like to...
0
1980
by: Achim Domma (SyynX Solutions GmbH) | last post by:
Hi, in my application I suddenly get the error: "An error has occurred because a control with auto-generated id 'main:institutionManagement:institutionOverview' could not be located to raise...
7
1161
by: Steven W. Orr | last post by:
In my class I have class Error(Exception): """Base class for exceptions in this module.""" pass class TransitionError(Error): """Raised when an operation attempts a state transition that's...
4
3546
by: Diego F. | last post by:
Hello. I'm migrating a VB6 application and I found a strange problem. The project is compiled in VB.NET 2005. The application loads making some checks, a database connection, and then waits until...
0
596
by: pauland80 | last post by:
<snip> <snip> Late thanks for your both answers! (Please excuse me for that) The problem was a bug in the device firmware. But before finding this, I dugg lightly in the pyserial source...
14
4314
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but...
0
7204
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,...
0
7342
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...
0
7464
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...
0
5586
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,...
0
4680
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...
0
3171
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...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
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...

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.