|
Everytime I have a few SqlDataAdapters + DataSets on my form, the designer takes
over 10+ minutes to just open up the form!
What the heck is wrong with it and how do I fix this? Anyone else have this problem?
Thanks
|
|
|
|
|
Hi,
I have a simple doubt.
I've created a struct TEST like this:
_value struct TEST
{
String *str;
int cont;
};
When I try to dynamically allocate TEST like this:
TEST *pTest = new TEST;
A compilation error says to me that 'a value type object cannot be dynamically allocated with managed members on C++ (nogc) heap'
I must use the 'str' variable within this structure, so how can I dynamically allocate TEST ?
Thanks in advance.
|
|
|
|
|
As covered in Chapter 1 of my "Extending MFC Applications with the .NET Framework", this can never work because __value types are allocated dynamically in the C++ heap (free store) whereas __gc types are allocated on the CLR heap. In your example, the TEST struct is a __value type but contains a __gc embedded type. If you need TEST::str to be of type String*, then you need to make the TEST struct a __gc struct. That will compile without errors.
Cheers,
Tom Archer
* Inside C# -Second Edition
* Visual C++.NET Bible
* Extending MFC Applications with the .NET Framework
|
|
|
|
|
Sorry if i've choose not suitable thread. I can't understand exactly wich forum I need.
How can I set position of printf (or cout) output? If I've already print a half screen of a text and I want return to some used position (e.g. 10th symbol) and start to overwrite existing text what should I do? No one knows how to do this under win32 please, help.
|
|
|
|
|
If you knew you were on the same line you could output some '\b's to backspace to the appropriate place, but it doesn't around like that's the case for you. As such you need to use the Win32 Console APIs, in particular SetConsoleCursorPosition(), but they don't intergrate particularly well with standard IO.
Depending on your specific needs, you might get away with just ensuring you've flushed your output before changing the cursor position. If not, you may need to switch to using the Console API for all your output.
-Blake
|
|
|
|
|
Hi there !
I need to use a web service written in VB.NET .
i want to write a C++ client to use the service. how can
we do it in C++.
Abhi....
|
|
|
|
|
Abhi Avasthi wrote:
how can
we do it
By asking the right people. Try the Visual C++ forum.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Dear friend,
I want to develope a telnet Client using C++ .net but
i am biggener in C++ .net so i dont know whether any telnet
API,function or calsses in C++ .net which will help to develope telnet Client.if u know then let me know thanx in advance.
Ar if
|
|
|
|
|
Hi,
I have a managed c++ project which I've included a CWinThread derived class (CMyThread). It works fine until I call 'pMyThread -> PostThreadMessage(...)'. It occurs a exception...
Is it possible to use 'PostThreadMessage' in a managed C++ project ?
I know that it's a little weird, but I really will appreciate if someone help me.
Thanks in advance.
|
|
|
|
|
Does your thread has a message pump?
"...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 believe it does...
I fact, I took this thread class (CMyThread) from a working UNmanaged c++ project, erased all the methods and kept only one... for test purposes. I've done no extra code.
So, from the class 'MyClient' (which is a managed c++ class) I call:
pMyThread -> PostThreadMessage(SWM_TEST, NULL, NULL);
I really don't know if Managed C++ works in the same way of Unmanaged C++ when it comes to processing messages.
Please, help me.
thanks.
|
|
|
|
|
You may try Win32 ::PostThreadMessage?
Also, what you mean by 'MyClient' (which is a managed c++ class) ?
Could you post it's header?
"...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
|
|
|
|
|
Win32 ::PostThreadMessage didn't work.
As I said before, I'm working in a Managed c++ project, so this MyClient class is a simple form class.
Within this class, I create a CMyThread object and after that I send a message to it. Like this:
MyClient::TestMethod()
{
CMyThread *pMyThread = new CMyThread();
pMyThread -> PostThreadMessage(SWM_TEST, NULL, NULL);
}
thanks.
|
|
|
|
|
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.
|
|
|
|