|
MyClient::TestMethod()<br />
{<br />
CMyThread *pMyThread = new CMyThread();<br />
pMyThread -> PostThreadMessage(SWM_TEST, NULL, NULL);<br />
}
Me think, you have an obvious error:
You are forgetting to call CreateThread()...
As well as, see my comments below.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I'm already calling CreateThraed() within the constructor of CMyThread...
|
|
|
|
|
Do you have any kind of sync between your main thread and CMyThread?
The only thing I could think of is that when you had CMyThread as unmanaged it was executing pretty fast without JIT involved and therefore by the time you PostThreadMessage CMyThread already had message queue. Now, when you moved CMyThread into managed JIT get's involved, more time gets spend on CMyThread creation, therefore by the time you PostThreadMessage message queue on CMyThread is not yet getting created.
Just a clue. Not strong but possible. Try to delay your main thread and see what happens.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
The sleep didn't work too...
I didn't type any additional code to synchronize the main thread with CMyThread, because it has already worked in the unmanaged project. Maybe you're right... with this 'JIT' involved it works in other way.
Can I manually synchronize the main thread and CMyThread ?
Sorry for my ignorance.
thanks.
|
|
|
|
|
What error are you getting?
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
The message is like that:
Debug Assertion Failed !
Program: MyProgram.exe
File: f:\vs70builds\3077\vc\MFCATL\ship\altmfc\include\
afxwin2.inl
Line: 997
|
|
|
|
|
So, go tot this file and see what assertion is about...
Also, put a breakpoint in yours threads InitInstatnce/Run functions and see if you heat them...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I found it !
When it returns from CreateThread(), the m_hThread = 0x000000
So, thread handle is null. The only problem now is that the CreateThread() is returning TRUE. That's why I thought the handle is ok... but it doesn't.
Thanks very much !
Sorry for disturbing you.
I'm at work, so I've got to go home now...
If I keep having problems, I will ask you for help.
Thanks again !
|
|
|
|
|
Hello everyone! I'm new here, and hopefully this is the right place to be. (Other forums haven't helped me in my search for information.) Last year, I wrote a web application with Visual Studio 6.0. I had ASP pages using JScript under IIS 5.0/Win2k server. To handle my business logic and database access, I wrote a COM component using VC++ 6.0. The COM component accessed the Oracle database using OLE DB via ATL - no ADO was used.
My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003??
I realize that nobody uses straight OLE DB anymore. (It was hard enough to find the OLE DB SDK 2.0 book last year!) So I'll be using ADO.NET instead, which means I'll be using Managed C++. I found a great example on how to use ADO.NET from MC++ from this website (link is http://www.codeproject.com/managedcpp/adonet_mcpp.asp?target=ado%2Enet%7Cprimer%7Cusing%7Cmanaged ).
But I can't seem to find any help on designing a component for use with ASP! Perhaps I'm using the wrong term? Every search I've done for ".NET component" has pointed me to text boxes, or data grids, or the term "object"- and "Object" has pointed me back to text boxes and data grids.
I want to stick with Managed Visual C++ for performance reasons. With the VC++ COM component, the server didn't even come close to bogging down- very cool! So I can't bring myself to write everything in ASP.NET, as most of the examples on the 'net seem to do. I want to write a component (or whatever the current terminology is?) that I can access from anywhere- from ASP.NET, from WSH, from VB.NET, etc! How do I do it?
I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support?
In fact, you know what I'd really like? I started off with a book by Wrox Press, called "Beginning Components for ASP using VB, VC++, and ATL". That book tied -everything- together for me, and started me off in the right direction. Is there such a book for .NET?
Thanks in advance! This is driving me nuts- I've figured out everything else, but I don't know how to convert my component into .NET technology. I know I could use my old COM DLL from .NET, but this is probably the best time for me to upgrade my application. I don't want to be locked into using COM for the next 5 years.
-Thomas
|
|
|
|
|
|
Thanks for the fast reply! But, that appears to be a link to old COM stuff, not a .NET equivalence. I already have my COM component written; I want to re-do it in Managed C++ .NET, not unmanaged. My goal is to not use COM anymore, but to use whatever the .NET equivalence is. And I don't want to use my old COM from .NET.
Or did I misunderstand your link?
Thanks!
-Thomas
|
|
|
|
|
ThomasH1 wrote:
But I can't seem to find any help on designing a component for use with ASP!
Just use COM interop (see the link below, and Managed Extensions for C++ and COM Interoperability Tutorial[^]). If you follow the guidelines listed, you can use a .NET component just like any COM component.
ThomasH1 wrote:
I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support?
.NET is by default free-threaded, but it's not very hard to make a given thread be an STA Apartment thread. Basically, you just set the current thread's ApartmentState to STA:
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
You'll want to do this in the entry point (WinMain) method.
In C#/VB.NET, you can also use the STAThreadAttribute attribute on the entry point to ensure that the main thread is STA by default:
[STAThread]
public static void Main(string args)
...
...but I don't know if this works in MC++.
Here's a reference on threading in .NET: Managed and Unmanaged Threading[^]. It mainly deals w/C# and VB.NET, but it's also relevant to MC++. There's also a reference section on Exposing .NET Framework Components to COM[^], which might help.
|
|
|
|
|
jdunlap wrote:
ThomasH1 wrote:<br />
But I can't seem to find any help on designing a component for use with ASP! <br />
Just use COM interop (see the link below, and Managed Extensions for C++ and COM Interoperability Tutorial[^]). If you follow the guidelines listed, you can use a .NET component just like any COM component.
But, one problem- like I said, I don't want to use COM interop- I don't want anything to do with COM! Or are you telling me that COM is the only way to do what I want?
I don't think that's what you're saying, because you just mentioned a ".NET component"- how do I make a .NET component??? That's my big question! (grin) I dug up some more info, specifically, http://www.asptoday.com/contentprint.asp?id=617, "Creating a DB Component with C# and ADO.NET", and the guy has me make a new C# class. Is that what I'd do in managed C++? Just make a class? And that would become my .NET component, and I could reference that component from ASP pages? There's no more DLL registration (regsvr32), it's all "automatic" somehow, right?
Also, with regards to threads- from the way you wrote your message, and from what I see at managed & unmanaged threading, it seems that manual threading code is only needed for COM interop- is that correct?
Thanks!
-Thomas
|
|
|
|
|
ThomasH1 wrote:
My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003??
Okay, I know I'm replying to myself, but I think I might've found what I was looking for. It was above a link in the MSDN docs that jdunlap pointed me to. Link is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp , "Developing Components".
The docs are written for VB & VC# (figures), but I think I can apply it to MC++. One bit jumps out at me, under the "Class vs Component vs Control" section, under the Container & Site heading. It says "If you are developing components...for Web Forms pages (ASP.NET pages), you do not have to implement containers or sites". I've got more reading to do, but can I assume that ASP will take care of threading?
Thanks!
-Thomas
|
|
|
|
|
I know the answer is simple , so simple that mr simple the village simpleton of simple village would find it very simple. But do you think I can see the answer ? No , its friday and I finish early and what happens ? This ....
I have the job of wrapping a V6 DLL in a shiney new managed dll. So to get me into it I write a very very simple app:-
An unmanaged c++ class that has a show method that calls AfxMessageBox and says "Hello World" (Well its Friday what do you want , originality?).
Then I make a wrapper which has a pointer to the unmanaged , calls the new and delete on the unmanaged in its nice new shiny managed constructors and destructors , and has its own Show() which calls the unmanaged show().
What happens is I get an unresolved external on new and delete . It is looking for a mangled new and delete .MSDN even says use the unmanaged new and delete , presumably for this reason . How do I get around it and force the call to the unmanaged new ? Overloading the new in the unmanaged class is one option that I would rather avoid ,I would prefere to leave the unmanaged alone ( the real world classes are immense and I do not want to touch them ). So come on tell me what I am missing, I know it is obvious , I just cannot see it.
I am sure that writing in C# for months has caused my C++ neurons to sulk , they are just sitting around in my Cortex (or wherever) saying , 'bloody told you so , wouldn't listen to us !' . Help , with minimal sarcasm , would be greatly appreciated.
|
|
|
|
|
One question, is your MC++ project set to mixed mode or pure mode (for producing managed assemblies)? If it is already mixed mode, I'm stumped. I haven't yet used both unmanaged and managed classes in an MC++ project yet. Actually, I haven't done much MC++. I still code some shell extensions and ActiveX controls now and then to help keep my C++ neurons firing, but they just don't fire like they used to after a couple years on C#!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Are you aware of __nogc new?
|
|
|
|
|
Hi All , i am new to Visual Studio.Net and wanna ask a beginner level question.please reply if anyone knows about it.
I am using Visual Studio .Net 2002, Whenever i complie and run any sample a from Msdn2002\Disk1\Samples\VC\ManagedExtensions\WindowsForms,I always got a Console window and then the original form (dialog) appears on the screen. can some please tell me how to hide the Console Window ?
remember there is only one sample which dose not show the Console windows (DOS) before showing the main dialog...
\Msdn2002\Disk1\Samples\VC\ManagedExtensions\WindowsForms\calculator
|
|
|
|
|
I accept I may not be the brightest chap I know , but can someone explain to me why when I write managed C++ my source code goes in the .h file and my includes go in my .cpp ?
|
|
|
|
|
|
|
Andrew Torrance wrote:
managed C++ my source code goes in the .h
Templated code? Templates belong in the .h
Andrew Torrance wrote:
my includes go in my .cpp
#include s belong in the .cpp, unless you *absolutly* need to have them in the .h, like you need for the includes of member variables.
Maybe its alright, or maybe your IDE needs ist weekend as well...
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Oops. Change the search start date and i found a question pertaining to this already. Seems to be a problem with vs.net 2002.
|
|
|
|
|
I'm trying to implement a collection class based on arraylist for a class library and I'm not sure how i'm supposed to get an indexer working with a covariant return type. I know covariance isn't spupporterd in mc++ but there's gotta be a way to create a custom collection......isn't there?
|
|
|
|
|
Hi,
Is there a 'WaitForSingleObject()' similar method in managed C++ ?
thanks.
|
|
|
|
|