|
|
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.
|
|
|
|
|
|
The code below is my original unmanaged C++ code:
//**********************************************
UINT ThreadFunction(LPVOID pParam)
{
DWORD dwWait;
while (TRUE)
{
.
.
//do something
.
.
dwWait = WaitForSingleObject(m_event,1000);
if (dwWait == WAIT_OBJECT_0)
break;
}
return 0;
}
//**********************************************
I want to implement something like this.
Can you help me ?
Thanks in advance,
Camilo.
|
|
|
|
|
Looks like you want to use the ManualResetEvent/AutoResetEvent:
AutoResetEvent *m_wait = new AutoResetEvent( false );
if( m_wait->WaitOne( 1000, <exit-context-true-or-false> ) )
do-this-if-wait-was-signalled;
else
do-this-if-timed-out;
-------
For the above Wait to continue, either the time has to elapse or another thread has to execute the following code:
m_wait->Set();
Check out MSDN help.
|
|
|
|
|
thanks for your help !!!
|
|
|
|
|
Hi
Why are DataGrids in C++ .NET so slow?
I am creating a dataset, and a data table with a single row, and it takes a couple of seconds to display the initial data in a datagrid, what am i doing wrong?
cheers
|
|
|
|
|
I have also noticed this
on the first instantiation the system runs slow and for every other after the code runs much faster...
wish I could answer this one
|
|
|
|
|
Hi
Why are DataGrids in C++ .NET so slow?
I am creating a dataset, and a data table with a single row, and it takes a couple of seconds to display the initial data in a datagrid, what am i doing wrong?
cheers
|
|
|
|
|
I am from China, so please forgive my poor English.
I've got a terrible question when i try to use [FieldOffset ..] in C# to simulate the function of "union" in C.
this my code:
[StructLayout(LayoutKind.Explicit)]
public struct union
{
[FieldOffset(0)]
public union1 u1;
[FieldOffset(0)]
public union2 u2;
}
public struct union1
{
[MarshalAs (UnmanagedType.ByValArray,SizeConst=2)]
public byte[] arra1;
}
public struct union2
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst=2)]
public byte[] arra2; //when I turn "byte" type to "int", it is OK! Or if i turn both "byte" to "int" in union1 and union2, it is OK too! ???
}
public void testUnion()
{
union u;
}
that is , I want to make a simple union comprising two "byte" Array at the
same offset, it's compiled successfully, but when i run testUnion(), i get a "System.TypeLoadException". What's more strange is that when i turn one or both of the two "byte" Array to "int" Array (or "long"), it just run Ok!
Any help will be deeply appreciated!
|
|
|
|
|
What is the best way to get x-number of bytes of memory into a byte array and back.
Basically I am trying to copy some unmanaged memory into and out of a DirectPlay NetworkPacket. I haven't found a clean (or semi-clean) solution yet.
Any ideas out there?
Thanks!
|
|
|
|