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

Shutdown Exception: "The string binding is invalid"

Hi,

I have a mixed C#, managed C++ and unmanaged C++ project.

The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this gives no problems
whatsoever. However, upon shutdown an exception pops up:
"The string binding is invalid"

If I call the singleton method from inside a purely unmanaged class, I
receive no exceptions during shutdown. Access to the singleton instance is
achieved through a static member function in the unmanaged class. Is there
anything special going on when calling static functions from a managed
class?

It's a little hard to describe the problem thoroughly without showing the
entire code (which is quite large), so please let me know of any points
you'd like me to elaborate on.

I can provide stack traces etc. upon request.

Thanks!
Apr 8 '06 #1
7 9482
Can you provide some sample code of how you create and release the managed
code from the unmanaged code?

That may provide some insights into why it's happening.

Pete

"Søren Dreijer" <bl**@bluh.net> wrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a mixed C#, managed C++ and unmanaged C++ project.

The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this gives no
problems whatsoever. However, upon shutdown an exception pops up:
"The string binding is invalid"

If I call the singleton method from inside a purely unmanaged class, I
receive no exceptions during shutdown. Access to the singleton instance is
achieved through a static member function in the unmanaged class. Is there
anything special going on when calling static functions from a managed
class?

It's a little hard to describe the problem thoroughly without showing the
entire code (which is quite large), so please let me know of any points
you'd like me to elaborate on.

I can provide stack traces etc. upon request.

Thanks!

Apr 8 '06 #2
I don't create or release the managed code from unmanaged code (not unless I
misunderstand how managed c++ works, that is).

What I'm doing is essentially this:

In a managed C++ class' constructor I call upon an unmanaged singleton's
static Instance() member function. It doesn't matter whether the actual
object instance is created before or after the Instance() call in managed
code. I get the exception either way. If this is the first call to the
singleton, an instance is created like this:

// Make the run-time destroy the singleton automatically
static T theInstance;
m_psInstance = &theInstance;

Oh, and I should probably note that the destructor of the singleton is not
called before the exception occurs. As far as I can tell from the code where
the debugger breaks, the exception occurs when cleaning up things related to
atexit() (which should also cover the static 'theInstance' above).
However, as I said above, if I call the singleton from purely managed code
BEFORE calling it from managed code, the exception still occurs. Hence why I
find it odd if there should be any clean-up problems related to the static
instance (as it was created in unmanaged code space).

If I call the singleton from unmanaged code only (and not managed), the
exception doesn't occur.

I guess I'm a bit shaky when it comes to defining the boundary between
unmanaged and managed c++. I mean, I'm using the "#pragma unmanaged" and
"#pragma managed" directives to specify which files are unmanaged and
managed, but I'm unsure how this plays out in run-time when calling classes,
which were included as unmanaged, from managed c++.

What an essay..

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:XL********************@giganews.com...
Can you provide some sample code of how you create and release the managed
code from the unmanaged code?

That may provide some insights into why it's happening.

Pete

"Søren Dreijer" <bl**@bluh.net> wrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a mixed C#, managed C++ and unmanaged C++ project.

The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this gives no
problems whatsoever. However, upon shutdown an exception pops up:
"The string binding is invalid"

If I call the singleton method from inside a purely unmanaged class, I
receive no exceptions during shutdown. Access to the singleton instance
is achieved through a static member function in the unmanaged class. Is
there anything special going on when calling static functions from a
managed class?

It's a little hard to describe the problem thoroughly without showing the
entire code (which is quite large), so please let me know of any points
you'd like me to elaborate on.

I can provide stack traces etc. upon request.

Thanks!


Apr 9 '06 #3
Søren,

This doesn't relate to C#, you might get better answers when posting to the
vc NG at "microsoft.public.dotnet.languages.vc" or/and
"microsoft.public.mfc.vc" as I have the impression you are using MFC in your
unmanaged code.

Willy.

"Søren Dreijer" <bl**@bluh.net> wrote in message
news:Os*************@TK2MSFTNGP05.phx.gbl...
|I don't create or release the managed code from unmanaged code (not unless
I
| misunderstand how managed c++ works, that is).
|
| What I'm doing is essentially this:
|
| In a managed C++ class' constructor I call upon an unmanaged singleton's
| static Instance() member function. It doesn't matter whether the actual
| object instance is created before or after the Instance() call in managed
| code. I get the exception either way. If this is the first call to the
| singleton, an instance is created like this:
|
| // Make the run-time destroy the singleton automatically
| static T theInstance;
| m_psInstance = &theInstance;
|
| Oh, and I should probably note that the destructor of the singleton is not
| called before the exception occurs. As far as I can tell from the code
where
| the debugger breaks, the exception occurs when cleaning up things related
to
| atexit() (which should also cover the static 'theInstance' above).
| However, as I said above, if I call the singleton from purely managed code
| BEFORE calling it from managed code, the exception still occurs. Hence why
I
| find it odd if there should be any clean-up problems related to the static
| instance (as it was created in unmanaged code space).
|
| If I call the singleton from unmanaged code only (and not managed), the
| exception doesn't occur.
|
| I guess I'm a bit shaky when it comes to defining the boundary between
| unmanaged and managed c++. I mean, I'm using the "#pragma unmanaged" and
| "#pragma managed" directives to specify which files are unmanaged and
| managed, but I'm unsure how this plays out in run-time when calling
classes,
| which were included as unmanaged, from managed c++.
|
| What an essay..
|
| "Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
| news:XL********************@giganews.com...
| > Can you provide some sample code of how you create and release the
managed
| > code from the unmanaged code?
| >
| > That may provide some insights into why it's happening.
| >
| > Pete
| >
| > "Søren Dreijer" <bl**@bluh.net> wrote in message
| > news:%2******************@TK2MSFTNGP03.phx.gbl...
| >> Hi,
| >>
| >> I have a mixed C#, managed C++ and unmanaged C++ project.
| >>
| >> The managed class calls a method which exists in an unmanaged singleton
| >> class. During the entire lifetime of the application, this gives no
| >> problems whatsoever. However, upon shutdown an exception pops up:
| >> "The string binding is invalid"
| >>
| >> If I call the singleton method from inside a purely unmanaged class, I
| >> receive no exceptions during shutdown. Access to the singleton instance
| >> is achieved through a static member function in the unmanaged class. Is
| >> there anything special going on when calling static functions from a
| >> managed class?
| >>
| >> It's a little hard to describe the problem thoroughly without showing
the
| >> entire code (which is quite large), so please let me know of any points
| >> you'd like me to elaborate on.
| >>
| >> I can provide stack traces etc. upon request.
| >>
| >> Thanks!
| >>
| >
| >
|
|
Apr 9 '06 #4
MFC? I'm using standard C++ code; no MFC anywhere. Not sure where you get
that impression..

I'll have a go in the .vc newsgroup though.

--Søren

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Søren,

This doesn't relate to C#, you might get better answers when posting to
the
vc NG at "microsoft.public.dotnet.languages.vc" or/and
"microsoft.public.mfc.vc" as I have the impression you are using MFC in
your
unmanaged code.

Willy.

"Søren Dreijer" <bl**@bluh.net> wrote in message
news:Os*************@TK2MSFTNGP05.phx.gbl...
|I don't create or release the managed code from unmanaged code (not
unless
I
| misunderstand how managed c++ works, that is).
|
| What I'm doing is essentially this:
|
| In a managed C++ class' constructor I call upon an unmanaged singleton's
| static Instance() member function. It doesn't matter whether the actual
| object instance is created before or after the Instance() call in
managed
| code. I get the exception either way. If this is the first call to the
| singleton, an instance is created like this:
|
| // Make the run-time destroy the singleton automatically
| static T theInstance;
| m_psInstance = &theInstance;
|
| Oh, and I should probably note that the destructor of the singleton is
not
| called before the exception occurs. As far as I can tell from the code
where
| the debugger breaks, the exception occurs when cleaning up things
related
to
| atexit() (which should also cover the static 'theInstance' above).
| However, as I said above, if I call the singleton from purely managed
code
| BEFORE calling it from managed code, the exception still occurs. Hence
why
I
| find it odd if there should be any clean-up problems related to the
static
| instance (as it was created in unmanaged code space).
|
| If I call the singleton from unmanaged code only (and not managed), the
| exception doesn't occur.
|
| I guess I'm a bit shaky when it comes to defining the boundary between
| unmanaged and managed c++. I mean, I'm using the "#pragma unmanaged" and
| "#pragma managed" directives to specify which files are unmanaged and
| managed, but I'm unsure how this plays out in run-time when calling
classes,
| which were included as unmanaged, from managed c++.
|
| What an essay..
|
| "Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
| news:XL********************@giganews.com...
| > Can you provide some sample code of how you create and release the
managed
| > code from the unmanaged code?
| >
| > That may provide some insights into why it's happening.
| >
| > Pete
| >
| > "Søren Dreijer" <bl**@bluh.net> wrote in message
| > news:%2******************@TK2MSFTNGP03.phx.gbl...
| >> Hi,
| >>
| >> I have a mixed C#, managed C++ and unmanaged C++ project.
| >>
| >> The managed class calls a method which exists in an unmanaged
singleton
| >> class. During the entire lifetime of the application, this gives no
| >> problems whatsoever. However, upon shutdown an exception pops up:
| >> "The string binding is invalid"
| >>
| >> If I call the singleton method from inside a purely unmanaged class,
I
| >> receive no exceptions during shutdown. Access to the singleton
instance
| >> is achieved through a static member function in the unmanaged class.
Is
| >> there anything special going on when calling static functions from a
| >> managed class?
| >>
| >> It's a little hard to describe the problem thoroughly without showing
the
| >> entire code (which is quite large), so please let me know of any
points
| >> you'd like me to elaborate on.
| >>
| >> I can provide stack traces etc. upon request.
| >>
| >> Thanks!
| >>
| >
| >
|
|

Apr 9 '06 #5
Well, I assumed you were using MFC because it's not uncommon to see this
issue at program exit time when managed code interops with C++ code that
uses MFC clases. Of course you can run into the same issue without using any
of the MFC classes.
This same exception is getting raised, when you call into managed code via a
COM interface or a managed delegate from the unmanaged DllMain while you are
processing DLL_PROCESS_DETACH, after the CLR has started shutting down. The
exception is an indication that executing managed code is no longer
possible.

Willy.

"Søren Dreijer" <bl**@bluh.net> wrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
| MFC? I'm using standard C++ code; no MFC anywhere. Not sure where you get
| that impression..
|
| I'll have a go in the .vc newsgroup though.
|
| --Søren
|
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
| news:%2****************@TK2MSFTNGP03.phx.gbl...
| > Søren,
| >
| > This doesn't relate to C#, you might get better answers when posting to
| > the
| > vc NG at "microsoft.public.dotnet.languages.vc" or/and
| > "microsoft.public.mfc.vc" as I have the impression you are using MFC in
| > your
| > unmanaged code.
| >
| > Willy.
| >
| > "Søren Dreijer" <bl**@bluh.net> wrote in message
| > news:Os*************@TK2MSFTNGP05.phx.gbl...
| > |I don't create or release the managed code from unmanaged code (not
| > unless
| > I
| > | misunderstand how managed c++ works, that is).
| > |
| > | What I'm doing is essentially this:
| > |
| > | In a managed C++ class' constructor I call upon an unmanaged
singleton's
| > | static Instance() member function. It doesn't matter whether the
actual
| > | object instance is created before or after the Instance() call in
| > managed
| > | code. I get the exception either way. If this is the first call to the
| > | singleton, an instance is created like this:
| > |
| > | // Make the run-time destroy the singleton automatically
| > | static T theInstance;
| > | m_psInstance = &theInstance;
| > |
| > | Oh, and I should probably note that the destructor of the singleton is
| > not
| > | called before the exception occurs. As far as I can tell from the code
| > where
| > | the debugger breaks, the exception occurs when cleaning up things
| > related
| > to
| > | atexit() (which should also cover the static 'theInstance' above).
| > | However, as I said above, if I call the singleton from purely managed
| > code
| > | BEFORE calling it from managed code, the exception still occurs. Hence
| > why
| > I
| > | find it odd if there should be any clean-up problems related to the
| > static
| > | instance (as it was created in unmanaged code space).
| > |
| > | If I call the singleton from unmanaged code only (and not managed),
the
| > | exception doesn't occur.
| > |
| > | I guess I'm a bit shaky when it comes to defining the boundary between
| > | unmanaged and managed c++. I mean, I'm using the "#pragma unmanaged"
and
| > | "#pragma managed" directives to specify which files are unmanaged and
| > | managed, but I'm unsure how this plays out in run-time when calling
| > classes,
| > | which were included as unmanaged, from managed c++.
| > |
| > | What an essay..
| > |
| > | "Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
| > | news:XL********************@giganews.com...
| > | > Can you provide some sample code of how you create and release the
| > managed
| > | > code from the unmanaged code?
| > | >
| > | > That may provide some insights into why it's happening.
| > | >
| > | > Pete
| > | >
| > | > "Søren Dreijer" <bl**@bluh.net> wrote in message
| > | > news:%2******************@TK2MSFTNGP03.phx.gbl...
| > | >> Hi,
| > | >>
| > | >> I have a mixed C#, managed C++ and unmanaged C++ project.
| > | >>
| > | >> The managed class calls a method which exists in an unmanaged
| > singleton
| > | >> class. During the entire lifetime of the application, this gives no
| > | >> problems whatsoever. However, upon shutdown an exception pops up:
| > | >> "The string binding is invalid"
| > | >>
| > | >> If I call the singleton method from inside a purely unmanaged
class,
| > I
| > | >> receive no exceptions during shutdown. Access to the singleton
| > instance
| > | >> is achieved through a static member function in the unmanaged
class.
| > Is
| > | >> there anything special going on when calling static functions from
a
| > | >> managed class?
| > | >>
| > | >> It's a little hard to describe the problem thoroughly without
showing
| > the
| > | >> entire code (which is quite large), so please let me know of any
| > points
| > | >> you'd like me to elaborate on.
| > | >>
| > | >> I can provide stack traces etc. upon request.
| > | >>
| > | >> Thanks!
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Apr 9 '06 #6
I'm encoutering the same problem although my app uses winforms on .Net 1.1. After Application.Run() returns the same exception, Win32Exception "The string binding is invalid" is thrown.

Our application is complex in that is uses some complex eventing, threads, as well as some third party controls. I suspect something is getting garbage collected too soon, but I'm not certain of that.

What is the error message "The string binding is invalid" is supposed to mean anyway?

Dania.
---
Posted via www.DotNetSlackers.com
Apr 17 '06 #7
I'm encoutering the same problem although my app uses winforms on .Net 1.1. After Application.Run() returns the same exception, Win32Exception "The string binding is invalid" is thrown.

Our application is complex in that is uses some complex eventing, threads, as well as some third party controls. I suspect something is getting garbage collected too soon, but I'm not certain of that.

What is the error message "The string binding is invalid" is supposed to mean anyway?

Dania.
---
Posted via www.DotNetSlackers.com
Apr 17 '06 #8

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

Similar topics

2
by: Eirik M. | last post by:
Hi, I've got the following piece of code that's causing me a bit of a problem XmlDocument doc = new XmlDocument (); XmlNode rootNode = doc.CreateNode (XmlNodeType.Element, "usersettings",...
6
by: TS | last post by:
Hi, i have a problem validating xml against schema. I used http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx validator and it says it is fine. Can you tell me why this doesn't work? ...
5
by: Horst Walter | last post by:
What is wrong here? IPAddress ipAddress = IPAddress.Parse("10.10.20.1"); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, this.port); this.tcpClient = new TcpClient(ipEndPoint); // PROBLEM HERE...
2
by: Boniek | last post by:
Hi, How I can create property to binding with other objects. I want to create a data object which work as a DataTable. DataTable contains columns and dataTable is used to binding with a textBox...
3
by: Jimski | last post by:
Hello all, I am having a problem where I get an error message when I call FlushFinalBlock when decrypting my encrypted text. I am using the Rijndael algorithm. The error message is "Length...
1
by: Valerie Hough | last post by:
Is there a C# class that will help convert strings that include fractions ( "2 1/2" e.g.) to doubles ? Convert.ToDouble() throws an invalid input format exception. Obviously I can write code to...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
5
by: lds | last post by:
I am getting the following error: The "SendUsing" configuration value is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the...
10
by: Water Cooler v2 | last post by:
I've asked myself this question in the past but couldn't afford more time to it (I program other languages for my bread and butter), so I'll ask now since it's never too late. What does the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.