473,378 Members | 1,457 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,378 software developers and data experts.

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.VisualBasic.CompilerServices.LateBinding .LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)

The specific call that is failing is:

objShareCfg =
objShare.INetSharingConfigurationForINetConnection (objNetConn)

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("HNetCfg.HNetShare")

to

Dim objShare As New NETCONLib.NetSharingManagerClass

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

System.Runtime.InteropServices.COMException (0x80041003): Exception from
HRESULT: 0x80041003.
at
NETCONLib.NetSharingManagerClass.get_INetSharingCo nfigurationForINetConnection(INetConnection
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 8428
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*****@newsgroups.nospam> wrote in message
news:uo**************@TK2MSFTNGP10.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.VisualBasic.CompilerServices.LateBinding .LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)

The specific call that is failing is:

objShareCfg =
objShare.INetSharingConfigurationForINetConnection (objNetConn)

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("HNetCfg.HNetShare")

to

Dim objShare As New NETCONLib.NetSharingManagerClass

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

System.Runtime.InteropServices.COMException (0x80041003): Exception from
HRESULT: 0x80041003.
at
NETCONLib.NetSharingManagerClass.get_INetSharingCo nfigurationForINetConnection(INetConnection
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*******@community.nospam> wrote in message
news:u1**************@TK2MSFTNGP10.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.microsoft.com> wrote in message
news:DL*************@TK2MSFTNGXA01.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.WriteLine("Trying to get
INetSharingConfigurationForINetConnection.")
objShareCfg =
objShare.INetSharingConfigurationForINetConnection (objNetConn)
Console.WriteLine("Got it.")

It is the call to objShare.INetSharingConfigurationForINetConnection 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.NetConnectionProps(objNetConn)
Catch ex As Exception
Console.WriteLine("Got exception " & ex.ToString & " while
trying to get connection properties")
Exit Sub
End Try

Console.WriteLine("*** 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 INetSharingConfigurationForINetConnection: " &
err.number
Set objShareCfg =
objShare.INetSharingConfigurationForINetConnection (objNetConn)
WScript.Echo "After INetSharingConfigurationForINetConnection: " &
err.number
If (IsObject(objShareCfg) = FALSE) Then
WScript.Echo("Unable 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.INetSharingConfigurationForINetConnection (objNetConn)
Catch
' Do nothing - let it fall through to the If test.
End Try

If Not IsReference(objShareCfg) Then
Console.WriteLine("Failed to get
INetSharingConfigurationForINetConnection")
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 misunderstanding please feel free to post here.
BTW: for ICS(Internet Connection Sharing) issue you may also try to post in
the group below.
microsoft.public.windows.networking.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
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:...
1
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...
8
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...
4
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...
6
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...
1
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...
2
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....
160
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...
2
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: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.