473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do you get a text description of the last Win32 error?

I see System.Runtime.InteropServices.Marshal.GetLastWind 32Error, but I see
no method to get a string based on that error. Do I need to use the Win32
function FormatMessage? If so, that defeats the purpose of C# having
GetLastWin32Error. Since FormatMessage does so many things besides look up
error messages, it tends to be a bit of a burden even in C++. I hate to
think of what calling it would be like under C#.
----------
Will Pittenger
E-Mail: mailto:wi************@verizon.net
All mail filtered by Qurb (www.qurb.com)
Nov 15 '05 #1
1 10123
Will,
I see System.Runtime.InteropServices.Marshal.GetLastWind 32Error, but I see
no method to get a string based on that error. Do I need to use the Win32
function FormatMessage?


No, you can do

Win32Exception ex = new Win32Exception();
string errMsg = ex.Message;

The Win32Exception class internally checks GetLastWin32Error and
retrieves the corresponding error message.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2

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

Similar topics

5
by: Bill | last post by:
I have perhaps not explained myself clearly, so I'll try it this way. In the code below, where it says "I'd like to include my navigation bar here" is the place I'd like to insert a navigation bar...
0
by: eddie wang | last post by:
I have the following asp runtime error 8007045a. How to response.write its text description? Thanks. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
0
by: Tom | last post by:
I can't debug my asp.net projects. for some reason i'm getting an error saying that i don't have permission and i should be added to the debuggers group. I added my domain user, my aspnet user and...
9
by: C.K | last post by:
Can I enter a two-line text description on a button, chr(13) doesn't seem to do anything ?
4
by: kieran | last post by:
Hi, I import data every evening through a scheduled task from a text file. Once the data is imported, an email is sent to a user saying how much data etc.. was in the file. In case the file...
5
by: Christian Traber | last post by:
Hi! just playing with tablespaces... - moved a existing table to a new tablespace - tried to move it back to default tablespace (ALTER TABLE accounts SET TABLESPACE pg_default;) Got the...
2
by: RdS | last post by:
Hello, I use sourcesafe and vb 2003 for my dev environment. on the sourcesafe server I also have sql2005 and reporting services installed. The web app references this sql server for db. When...
2
by: Eng Teng | last post by:
Where is the part to set when my mouse pointer move to textbox or label or buton it will display text description ? Regards, Tee
1
by: csharpula csharp | last post by:
Hello, I got the following message when trying to run a c# executable aaa.exe is not a valid Win32 application. which worked before it was coped to som eother location. Now it's not working...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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,...
0
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...
0
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...

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.