473,836 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Struggling to diagnose a COM exception error (80041003)

I'm rewriting some existing VBScript into VB.Net code. It was all going well
until I hit the following error when testing the code:

System.Runtime. InteropServices .COMException (0x80041003)
at Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateGet(O bject o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)

The specific call that is failing is:

objShareCfg =
objShare.INetSh aringConfigurat ionForINetConne ction(objNetCon n)

I've now referenced NETCONLIB, which is the COM interface for the INet
stuff. If I change the DIM statements for objShareCfg and objNetConn to the
correct types, I still get the COMException.

If I change the initial object creation part from:

objShare = CreateObject("H NetCfg.HNetShar e")

to

Dim objShare As New NETCONLib.NetSh aringManagerCla ss

I still get the COMException but the location (not surprisingly) changes:

System.Runtime. InteropServices .COMException (0x80041003): Exception from
HRESULT: 0x80041003.
at
NETCONLib.NetSh aringManagerCla ss.get_INetShar ingConfiguratio nForINetConnect ion(INetConnect ion
pNetConnection)

The VBScript runs without error under the same user account on the same
computer. The VB.Net code runs without error on the development machine :-(.

Anyone got any suggestions on what I can try next?

--Philip
Nov 21 '05 #1
8 8476
Hi Philip,

I just Googled that error number and it seems like it's an "Admin Rights
Required" error code. This would make sense judging by what you're trying
to do (configure connection sharing?) and be consistent with it working fine
on your development machine. It's always wise to test an your software in a
separate Power User & Restricted User account, in case there are any
pitfalls you hadn't coded for.

Cheers,
Alex

"Philip Colmer" <pc*****@newsgr oups.nospam> wrote in message
news:uo******** ******@TK2MSFTN GP10.phx.gbl...
I'm rewriting some existing VBScript into VB.Net code. It was all going
well until I hit the following error when testing the code:

System.Runtime. InteropServices .COMException (0x80041003)
at Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateGet(O bject o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)

The specific call that is failing is:

objShareCfg =
objShare.INetSh aringConfigurat ionForINetConne ction(objNetCon n)

I've now referenced NETCONLIB, which is the COM interface for the INet
stuff. If I change the DIM statements for objShareCfg and objNetConn to
the correct types, I still get the COMException.

If I change the initial object creation part from:

objShare = CreateObject("H NetCfg.HNetShar e")

to

Dim objShare As New NETCONLib.NetSh aringManagerCla ss

I still get the COMException but the location (not surprisingly) changes:

System.Runtime. InteropServices .COMException (0x80041003): Exception from
HRESULT: 0x80041003.
at
NETCONLib.NetSh aringManagerCla ss.get_INetShar ingConfiguratio nForINetConnect ion(INetConnect ion
pNetConnection)

The VBScript runs without error under the same user account on the same
computer. The VB.Net code runs without error on the development machine
:-(.

Anyone got any suggestions on what I can try next?

--Philip

Nov 21 '05 #2

"Alex Clark" <qu*******@comm unity.nospam> wrote in message
news:u1******** ******@TK2MSFTN GP10.phx.gbl...
Hi Philip,

I just Googled that error number and it seems like it's an "Admin Rights
Required" error code. This would make sense judging by what you're trying
to do (configure connection sharing?) and be consistent with it working
fine on your development machine. It's always wise to test an your
software in a separate Power User & Restricted User account, in case there
are any pitfalls you hadn't coded for.

Cheers,
Alex


That was my first thought as well ... except for the fact that the original
VBScript works without errors on the same computer that the VB.NET code is
failing on. The account I'm using on that test computer is a restricted user
account.

I'm only reading the settings, not trying to change anything.

--Philip
Nov 21 '05 #3
Hi

It is strange that the working code did not work on another machine.
To isolate the problem, I suggest you try run the VB.NET App with
Administrator to see if that works.
You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

""Peter Huang" [MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:DL******** *****@TK2MSFTNG XA01.phx.gbl...
Hi

It is strange that the working code did not work on another machine.
To isolate the problem, I suggest you try run the VB.NET App with
Administrator to see if that works.
You may have a try and let me know the result.


The code does run with an administrator account.

I've put some extra WriteLine statements in the code to try to figure out
what is going on (as I don't have the debugger on the test machine). The
error is occuring inside a For loop:

For Each objNetConn In objEveryColl
Console.WriteLi ne("Trying to get
INetSharingConf igurationForINe tConnection.")
objShareCfg =
objShare.INetSh aringConfigurat ionForINetConne ction(objNetCon n)
Console.WriteLi ne("Got it.")

It is the call to objShare.INetSh aringConfigurat ionForINetConne ction that is
blowing up. What is strange, though, is that I don't think there is a
connection to interrogate here. The code afterwards goes:

Try
ConnectionProps = objShare.NetCon nectionProps(ob jNetConn)
Catch ex As Exception
Console.WriteLi ne("Got exception " & ex.ToString & " while
trying to get connection properties")
Exit Sub
End Try

Console.WriteLi ne("*** Connection : " & ConnectionProps .Name)

When I run this as an administrator, I get a bunch of connections listed and
then the code finishes. When I run this as myself, I get the SAME list of
connections listed but it then stops with the COM exception error. This
suggests that the For loop is getting it wrong, for some reason, when
running as a user account.

I could wrap a Try ... Catch around the code but I'm concerned that I'm
basically putting a sticking plaster over something that does run properly
in its original VBScript version.

--Philip
Nov 21 '05 #5
Hi

I have somewhat confused with your scenario.
When you run the code in a for loop as an administrator, if there is any
exception?
When there will have and when not?

If the code throw exception only when you run as an user account. I think
you may try to check the eventlog to see if there is any security log.
Or you may try to check the filemon or regmon to see if there is any denied.
http://www.sysinternals.com/Utilities/filemon.html
http://www.sysinternals.com/Utilities/regmon.html

Also if the VB Script code did not have error, did not export same output
when your run the same account?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6
I've done some more digging into the VBScript version. It has an "On Error
Resume Next" which was masking the COM exception.

The VBScript code does this:

For each objNetConn in objEveryColl
Dim objShareCfg
Dim ConnectionProps

WScript.Echo "Before INetSharingConf igurationForINe tConnection: " &
err.number
Set objShareCfg =
objShare.INetSh aringConfigurat ionForINetConne ction(objNetCon n)
WScript.Echo "After INetSharingConf igurationForINe tConnection: " &
err.number
If (IsObject(objSh areCfg) = FALSE) Then
WScript.Echo("U nable to retrieve Sharing Cfg Object")
WScript.Quit (2)
End If
...

When it gets the the Bluetooth connection on my PC, err.number changes to
0x80041003. HOWEVER, objShareCfg would appear to change to point to an
object since if I reset objShareCfg to Nothing just before the first
WScript.Echo, I still end up with an object after the COM Exception.

I guess that on the VB.Net side of things, I could do a try-catch and ignore
any exception raised by that call and just test for it being an object?

The Bluetooth code is from XP SP2 (i.e. the Microsoft version) so this might
suggest there is a problem in that code somewhere?

--Philip
Nov 21 '05 #7
Got to the bottom of it ...

The exception is being caused by a dial-up connection that is specific to
the user (i.e. not available to all users). Rewriting the VB.Net code thus:

Try
objShareCfg =
objShare.INetSh aringConfigurat ionForINetConne ction(objNetCon n)
Catch
' Do nothing - let it fall through to the If test.
End Try

If Not IsReference(obj ShareCfg) Then
Console.WriteLi ne("Failed to get
INetSharingConf igurationForINe tConnection")
End If

seems to emulate the VBScript more closely and "hide" the COM exception
error.

I don't know if someone at MS wants to investigate why the COM exception is
happening?

--Philip

Nov 21 '05 #8
Hi

In VB.NET you can still use the On Error Resume Next.
Also from your descript above, the problem lie in VB Script too, so it is a
underlying Unmanaged scenario issue.
Because the Administrator will work but not for certian user, so it is a
permission problem, the user has no permission to access the dialup
connection.
If I have any misunderstandin g please feel free to post here.
BTW: for ICS(Internet Connection Sharing) issue you may also try to post in
the group below.
microsoft.publi c.windows.netwo rking.firewall
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #9

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

Similar topics

5
13889
by: Geoffrey | last post by:
Hope someone can help. I am trying to read data from a file binary file and then unpack the data into python variables. Some of the data is store like this; xbuffer: '\x00\x00\xb9\x02\x13EXCLUDE_CREDIT_CARD' # the above was printed using repr(xbuffer). # Note that int(0x13) = 19 which is exactly the length of the visible text #
1
3513
by: Martin | last post by:
I use dbx and i got the following error: Reading GL_CliConnMgr core file header read successfully Reading ld.so.1 dbx: core file read error: address 0xff3e6000 not available dbx: core file read error: address 0xff3e70a0 not available dbx: warning: could not initialize librtld_db.so.1 -- trying libDP_rtld_db.so Make sure this is the same version of Solaris where the core dump
8
1414
by: Jason | last post by:
A week ago I posted a simple little hi-score routine that I was using to learn Python. I've only just managed to examine the code, and the responses that people gave, and I'm now seriously struggling to understand why things aren't working correctly. At present my code is as follows... import random
4
5621
by: Angus Comber | last post by:
Hello I have received a lot of help on my little project here. Many thanks. I have a struct with a string and a long member. I have worked out how to qsort the struct on both members. I can do a bsearch on the long member (nKey) but I am struggling to do a search using the string member. The code I am running appears below. It doesn't crash or anything. It is just that when I do the last bsearch using "192.168.1.3" I SHOULD find...
6
2264
by: Martin | last post by:
Hi, I had a page the other day for which the compiler just wouldn't recognize the fact that I had enabled session state in every possible way. I ended up moving the code that dealt with the Session object from code-behind to in-page and it worked. Didn't find an explanation though but it got me up again. Today it got worse. Now what sense does this make:
1
3348
by: caesarchen | last post by:
Dear all: The following is the situation,can any one share me idea to solve it? Windows 2000 + IIS6.0 + .NET Framework 1.1 6 projects, about 800 webforms and 300 .asmx programs Project cowork with nSheild HSM by writing custom COM+ using CSP CryptoAPI . 1. System will write some log in the candidate web service. 2. ASP.NET hangs.
2
4860
by: Kevin Burton | last post by:
I have an aspx page that is generating the error below. I want to solve this problem but in general I would like to know how I might best approach problems like this. Any suggestions? Thank you. Kevin Server encountered an internal error. For more information, turn on customErrors in the server's .config file.
160
4751
by: RG | last post by:
Greetings friends, This semester I have started a course in C programming. I was moving along fine until I reached to the topic of loops (feeling embarrassed among you elite programmers). My prof. would post program questions and the solutions online. For practice I would try to do the problems. I would reach to a certain point in the code, for example as far as error trapping, but when the loop arrives, like knowing whether to use...
2
6997
by: Darko Miletic | last post by:
Recently I wrote a dll in c++ and to simplify the distribution I decided to link with multithreaded static library (/MT or /MTd option). In debug everything works fine but in release I get this: parseMetadata.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) 2>libcpmt.lib(string.obj) : error LNK2001: unresolved external symbol "public: __thiscall...
0
9814
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
9666
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
10836
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
10543
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
10249
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
9368
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
6976
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
5819
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4447
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

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.