473,699 Members | 2,496 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 2360
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.co m

"Alan Roberts" <al**@statistix l.co.uk> wrote in message
news:u1******** ******@TK2MSFTN GP09.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.GetExce ptionForHR(your ErrorCode);

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**@statistix l.co.uk> wrote in message
news:u1******** ******@TK2MSFTN GP09.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
1831
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 be so special? py> sometup = 1,2 py> print sometup (1, 2) py> print 1,2,3, sometup
3
1975
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 environment this architecture works beautifully -- caller application gets negative HRESULT and error description from IErrorInfo object, and additional "log" information from that "ref" parameter: In .Net it just never returns that paramter...
2
5446
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 (although, when I exit from the property let code, if I check err.number and message, I get the error message I set in err.raise statement But my calling code never throw me into error handler if I set wrong
1
10519
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
5111
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 write the addition in C#. I've scoured the Internet for the procedures necessary to use this type of interoperability and feel comfortable with those so far (strong name, GAC, attributes, etc). My question: How does my C# component notify my...
0
1988
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 a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events." The exception is thrown in Page.ProcessPostData. I fully understand the
7
1166
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 not allowed.
4
3555
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 a timer raises a tick event. Well, in that point the application stops. I don't know why. The event doesn't raise up and the application closes without passing by close events. Sometimes I get that error when running step by step:
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 and found (to take with care!) :
14
4345
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 ignored when called. I can see the attribute using dir(self.__class__) on an instance, but when called, python enters __getattr__. If I correct the bug, the attribute calls work as expected and do not call __getattr__. I can't seem to make a simple...
0
9196
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
7784
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
6546
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
5879
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
4390
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
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
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 we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
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.