|
Have you looked around on MSDN?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
Can you even write a GINA dll using .NET code ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is it possible, or would a wrapper be needed?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello,
I try this but there are a lot of error (I try to cal a method of the original form "form" but i can't do it)
public void TraitementForm1()<br />
{<br />
<br />
}<br />
<br />
public void OuvertureForm2()<br />
{<br />
form2 ^maForm2 = gcnew form2();<br />
maForm2->Owner = this;<br />
maForm2->Show();<br />
}<br />
<br />
<br />
private void ButtonOk_Click(object sender, System.EventArgs e)<br />
{<br />
Form1 ^maForm1 = safe_cast<Form1 ^>(this->Owner);<br />
maForm1->TraitementForm1();<br />
}
How to resolve this
thank you
very much
aef
|
|
|
|
|
Hello all,
Is it possible to generate .NET 3.0 assemblies with C++/CLI under VS2005, or do I need VS2008? I have installed the WPF/WWF extensions, but these seem to be C#-only. Maybe there is some trick to make C++ use .NET 3.0?
|
|
|
|
|
You should be able to create .NET 3.0 assemblies under VS2005 with C# and VB.NET. I've been doing so for a while now. You have to install the WPF/WCF/WWF extensions from Microsoft. Not sure about C++/CLI, I would imagine there would be a way to do it. MSDN any help?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
You can just add them as references but it might be that the designers are only supported with C# :/
|
|
|
|
|
Let me add that the designer for WPF on C# Express (even with VS 2005 Standard Edition) really bites and recommend using the Expression Blend for the design part
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
if you're going to do much WPF stuff (and especially XAML) just save yourself the headache and use C#
|
|
|
|
|
Hi,
I create thred who call a methode whitch add on listView, bu unfortunately there are an Exception on execution in line listView2->Items->Add("zezeze");
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {<br />
Threading::Thread(gcnew ThreadStart(this, &Form1::Traitement));<br />
t->Start();<br />
<br />
}<br />
<br />
<br />
void Traitement( )<br />
{listView2->Items->Add("zezeze");}<br />
}
When i put MessageBox in place listView, he show me a message normusly, please Help me to resolve this great problem.
Thank you verry mutch
|
|
|
|
|
Hi,
An exception explains itself by giving a message, some additional information,
and a stack trace; if inner exceptions are present, these get explained too.
did you care to read any of that ?
would it not be useful to add it to your post, so others can see it ?
All we can do now is guess, and if we guess wrong all our efforts are lost.
|
|
|
|
|
Use The Force
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I do, if necessary.
I try the normal way first.
I bet it is an InvalidOperationException due to cross-thread violations
but dont want to waste message space, and everybody's time.
|
|
|
|
|
Hi,
can you shwou me, how a use force, an exeemple if it's possible,
thank you verry mutch.
|
|
|
|
|
I can not explain "The Force" to you; you will know when you have The Force,
not before that.
In the mean time, did you read my earlier reply, I was asking about the details
of the exception you are getting. That would bring us closer to a solution
for your problem.
|
|
|
|
|
hi,
the exception was :
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control 'listView2' accessed from a thread other than the thread it was created on.
but when i put messageBox, he show message nurmously,
How i can add in listView?
Thank you verry mutch
|
|
|
|
|
OK,
this is the problem: in Windows, each Control (such as a ListView) must be
handled by only one thread; the thread that creates the Control is the only
thread that successfully can read and write its properties, and execute its
methods. Violating this rule gives:
- on older .NET abnormal behavior, possibly a complete hangup
- on .NET 2.0 and better, by default, the exception you have got
Now typically each Control is linked somehow to another Control; a Button is
on a Form, a ListView is on a Form; clicking a Button that creates and shows
a dialog links that dialog to the original Button and Form, etc.
So normally all Controls belong to the main thread (also known as "GUI thread").
There are two ways to solve your problem:
- the easy way is have every Control be handled by the GUI thread, which
could mean, use a Forms.Timer, since that executes its Tick handler on the
GUI thread. The drawback is, if the Tick handler takes too long, your GUI
responsiveness will suffer
- use some other thread for calculating things, accessing a database, whatever,
but as soon as it needs to access a Control, let it ask the GUI thread to do
so. That can be organized by the Control.InvokeRequired property, and the
Control.Invoke or Control.BeginInvoke methods.
I suggest the latter; so read up on InvokeRequired and Invoke.
There are some good articles about it on CodeProject; my Sokoban article
shows a small example too (I used a Timers.Timer so I could demonstrate the
Invoke stuff).
|
|
|
|
|
hello,
In 1st, i used a Timer, who get a packets every tick, but my application became heavy, for this reason i would use a Thread.
With Timer:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {<br />
timer5->Interval=10;<br />
timer5->Start();<br />
}<br />
<br />
private: System::Void timer5_Tick(System::Object^ sender, System::EventArgs^ e) {<br />
<br />
While (there are packets which arrive ) {<br />
<br />
listView->Items->add (one paquets)<br />
<br />
}
Witht Thread { an exception on listView }
delegate void DelegateThreadTask();<br />
DelegateThreadTask ^ er;<br />
<br />
<br />
<br />
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {<br />
Threading::Thread(gcnew ThreadStart(this, &Form1::Traitement));<br />
t->Start();<br />
<br />
}<br />
.<br />
.<br />
.<br />
<br />
void Traitement( )<br />
{ while(true)<br />
{ThreadTask();<br />
Thread::Sleep(100); <br />
}<br />
<br />
}<br />
.<br />
.<br />
.<br />
void ThreadTask() <br />
{<br />
<br />
While (there are packets which arrive ) {<br />
<br />
listView->Items->add (one packets)<br />
<br />
}<br />
<br />
er = gcnew DelegateThreadTask(this, &Form1::ThreadTask);<br />
er->Invoke(); }<br />
<br />
<br />
<br />
Please hlep me,to get packets without heavy my système
Thank you verry mutch
|
|
|
|
|
Hi,
abbd wrote: listView->Items->add (one packets)
this probably is the offending line. As I explained before, a thread other than
the GUI thread is not allowed to do this, lictView belongs to the GUI thread.
Read up on InvokeRequired and Invoke(); you will need a delegate.
|
|
|
|
|
I make this:
delegate void DelegateThreadTask();<br />
.<br />
.<br />
.<br />
<br />
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {<br />
Threading::Thread(gcnew ThreadStart(this, &Form1::Traitement));<br />
t->Start();<br />
<br />
}<br />
.<br />
.<br />
.<br />
<br />
void Traitement( )<br />
{ while(true) {ThreadTask();Thread::Sleep(100);}<br />
<br />
}<br />
<br />
<br />
void ThreadTask() <br />
{listView2->Items->Add("zezeze");<br />
<br />
DelegateThreadTask ^ er = gcnew DelegateThreadTask(this, &Form1::ThreadTask);<br />
Invoke(er); <br />
}
but always there are an exception
how i can resolve this great problem
Thank you very mutch.
|
|
|
|
|
You did it again: what exception ?
anyhow I gave you the keywords, the suggestion to read some article,
and an example (in C#). I dont speak C++, I cant help you any further.
Bonne chance.
|
|
|
|
|
Hi,
i do this
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {<br />
oa[0] = sender;<br />
oa[1] = e;<br />
<br />
<br />
Thread ^th = gcnew Thread(gcnew ThreadStart(this, &Form1::Traitement));<br />
th->Start();<br />
<br />
<br />
}<br />
.<br />
.<br />
.<br />
this->Invoke(gcnew DelegateThreadTask(this,&BHIDS00::Form1::ThreadTask), oa);
but unfortunately, there are always exception, he show me line of
this->Invoke(gcnew DelegateThreadTask(this,&BHIDS00::Form1::ThreadTask), oa);
Thank you verry mutch
|
|
|
|
|
Hello All,
Although there is a wizard-generated AssemblyInfo.cpp file in my project, containing the default versioning directive:
[assembly:AssemblyVersionAttribute("1.0.*")]; ,
the generated assembly does not contain the version info resource (i.e. it does not get displayed as a tab in explorer's file properties).
I tried adding VersionInfo resource manually, but it uses hardcoded data, not the ones that are dynamically generated from the AssemblyInfo.cpp file.
How to set up a C++/CLI class library project to automatically include the appropriate version info?
|
|
|
|
|
Strange enough this seems to work fine if you use the C# compiler (the version information is included in the dll correctly) but the C++ compiler still needed the old-style RC, call it versioninfo.rc for instance.
There is an example of such a resource file at:
http://msdn2.microsoft.com/en-us/library/aa381058.aspx[^]
A problem that i have not solved is how to get the version from AssemblyInfo.cpp into the native resource-file.
A workaround i'm using now is: create a new file version.h the contains the version numbers and include it in both versioninfo.rc and AssemblyInfo.cpp.
Gr,
Jan
|
|
|
|