|
Yes, while I agree that that does work, what I really want to know is WHY cant I use Int32^ when things like String^ work just fine.
I think there should be some documentation somehwere that says "You can't serialize certain references.. <insert list of "bad" references>" somewhere.
Myabe there already is, but i can't find it.
|
|
|
|
|
Code is self explanitory. Adding braces around the for each block fixes it, but this shouldn't be required. Unless of course you can point me to something that says this is expected behaviour.
Jody Steele
-----CODE START-----
using namespace System;
using namespace System::Collections;
int main(array<System::String ^> ^args)
{
//Define a test array
ArrayList test;
//Populate it with some data
test.Add(3);
test.Add(4);
test.Add(13);
test.Add(42);
//Works as expected: WriteLine not called
if (false)
Console::WriteLine("Test");
//Works as expected: for not entered
if (false)
for(int i=0;i<test.Count;i++) {
Console::Write("for ");
Console::WriteLine(test[i]);
}
//UNEXPECTED: for each loop is entered!
if (false)
for each (int i in test) {
Console::Write("for each ");
Console::WriteLine(i);
}
}
-----CODE END-----
|
|
|
|
|
Just in case my message about what fixes it wasn't clear:
Bad:
----CODE----
if (false)
for each (int i in test) {
Console::Write("for each ");
Console::WriteLine(i);
}
----CODE END----
Good:
----CODE----
if (false) {
for each (int i in test) {
Console::Write("for each ");
Console::WriteLine(i);
}
}
----CODE END----
But yeah... Original question still stands: Is this a "feature" or a genuine bug?
|
|
|
|
|
Definitely looks like a bug to me.
Regards,
Nish
|
|
|
|
|
Hi Friends,
Is it possible to write a parser which will find all the variable names from any program( or language specific)...and then can we change the variable name in all the files by changing variable name at just only one place
Renjith
|
|
|
|
|
IS the "Replace in files" commands in VC not sufficient for that ? Do you want to do it programmatically ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
All I need to do is to send a structure via SerialPort Control which needs in return an array of Bytes, and then convert it back on the other side!
Can anyone help me here
I am getting pretty desperate here
Thanks
|
|
|
|
|
Hello,
you might want to give the BinaryFormatter class a try. It allows you to serialize and deserialize objects to and from a stream. As far as i know you could then retrieve the buffer from it or even write the stream to the serial port.
You will find it in this namespace:
System::Runtime::Serialization::Formatters::Binary;
Anyway, I cannot guarantee that it will actually work, because i haven't had the time yet to test it by my own.
Best regards Tobias
|
|
|
|
|
Hi all around there!
I´ve some Problems whith comiling a managed c++ programm written in vs2003 under vs2005 whith compiler-otion /clr:oldSyntax.
error c3767 occures at line: >CmbChnl1->Events->Dispose(); or CmbChnl1->get_Events()->Dispose();
and many other lines with the Dispose()-Function.
I found out something in the msdn, but it helps not very much.
It tells me that my system-own types are in .Net V2 private now.
Sorry, it's my first SW written in .Net and it's not written by myself.
Thank's a lot for helping!
|
|
|
|
|
C++/CLI does not allow you to call Dispose() anymore. You have to use delete to dispose. For example:
delete CmbChnl1->Events;
|
|
|
|
|
That doesnt fix the Problem, i got the same error-code now, (c3767: Function is not accessable) and after that a fatal error.
I try to disable all events of a form while actualizing the Data in Comboboxes.
construction:
public __gc class TransFreqView : public ModulView //public System::Windows::Forms::Form
{
public: TransFreqView()
{
GenerateComboArray();
InitializeComponent();
GenerateComboBoxes();
__mcTemp__3 = new ArrayList();
}
.....
public: void GenerateComboBoxes(void)
{
CmbChnl1->Items->AddRange(__mcTemp__1);
.....
public: System::Windows::Forms::ComboBox * CmbChnl1;
.....
public: System::Void CmbChnl1_SelectionChangeCommitted(System::Object * sender, System::EventArgs * e);
...
cpp-File:
void TransFreqView::UpdateView(void)
{
CmbChnlSetAll->Events->Dispose(); // old: CmbChnl1->get_Events()->Dispose();
....
Thanks a lot for help!
|
|
|
|
|
So, what is this CmbChnlSetAll->Events property is disposing! Also, if the Dispose() function is not accessible it is probably has protected or private access, and you are not required to manually dispose of its resources.
|
|
|
|
|
George L. Jackson wrote: C++/CLI does not allow you to call Dispose() anymore.
He is using /clr:oldSyntax option, so it should not be an issue.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
I believe your problem might be on how you set up your class to process disposal of resources. Make sure your class looks something like the following:
__gc class Test : public IDisposable
{
public:
Test() : disposed(false)
{
Console::WriteLine(__FUNCSIG__);
}
~Test()
{
Console::WriteLine(__FUNCSIG__);
Dispose(false);
}
void Dispose()
{
Console::WriteLine(__FUNCSIG__);
Dispose(true);
GC::SuppressFinalize(this);
}
private:
void Dispose(bool disposing)
{
Console::WriteLine(__FUNCSIG__);
if (!this->disposed)
{
if (disposing)
{
Console::WriteLine(S"Disposing managed resources");
}
Console::WriteLine(S"Cleaning up unmanaged resources");
}
disposed = true;
}
bool disposed;
};
I was able to execute Test::Dispose() without any problems. I complied this first in 2003 and did the wizard migration to 2005. The resulting command line:
/O2 /D "WIN32" /D "NDEBUG" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /FD /EHa /MD /Yu"stdafx.h" /Fp"Release\McppOld.pch" /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /nologo /c /Zi /clr:oldSyntax /TP /errorReport:prompt /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" /FU "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll"
Geo
-- modified at 19:25 Thursday 18th May, 2006
|
|
|
|
|
Hello all,
How to generate class diagrams from VS 2005 .net for C++ project?
Thanks and Regards
Madhu
|
|
|
|
|
If you have Microsoft Visio, you can create UML diagrams.
|
|
|
|
|
Hi,
I am trying write a generic dll/component in VC++ that could add a skin functionality to any application.
For example Win Xp SKins, Vista Skins, etc.
For applications that may also run on mobile devices.
I am not sure where/how to start!
Thanks!
http://www.appface.com
|
|
|
|
|
AryaSoft wrote: I am not sure where/how to start!
start by asking in the VisualC++/MFC forum, not this one.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
How would I go about using an unmanaged DLL in C# ? I have imported some functions using the [DllImports("mydll.dll")] directive which appears to work fine with functions that don't have inputs. But how would I for example use a function that takes the following params:
<br />
[Dllimport(@"mydll.dll")]<br />
public static extern bool Initialize( void * pInitStruct );<br />
The struct I need to use takes the form:
<br />
typedef struct tagInitStruct {<br />
long mS;<br />
long mE;<br />
const char* mAN;<br />
const char* mCAN;<br />
const char* mVI;<br />
const char* mPC;<br />
const char* mRS;<br />
} InitStruct , *InitStructPtr;<br />
How would I recreate that struct in C# and pass it to the DLL function?
I am new to C# BTW.
Thanks in advance.
|
|
|
|
|
This question should be in the C# forum.
Research PInvoke. A good resource pinvoke.net[^]
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
I am trying to convert a VB .NET application into C++ .NET, I am struggling with this task and would like some help. One of the main problems I have is with taking methods from a DLL file. Could you tell me what could I would have to enter into Form1.h to change declarations like this
Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, _<br />
ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _<br />
ByVal cbVer As Integer) As Boolean
into C++ code. I am not sure at all as to how to include dll files and their methods in a C++ application.
I am also having problems with the following method
capGetDriverDescriptionA(x, strName, 100, strVer, 100)
This method
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
belongs to the user32 dll file, but I am not sure as to how to link and import it.
Any help would be appreciated. If possible, please point me in the direction of some tutorials to help. I am a programmer who hasn't touched C++ in about a year, the last IDE I used was Visual C++ 6.0, so you can tell I need help.
|
|
|
|
|
Cantona2k wrote: I am trying to convert a VB .NET application into C++ .NET
Do you mean Managed C++ (VS 2002, 2003), C++/CLI (VS 2005) or even native C++?
Cantona2k wrote: Could you tell me what could I would have to enter into Form1.h to change declarations like this
Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, _
ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _
ByVal cbVer As Integer) As Boolean
into C++ code.
Just include Vfw.h, link to Vfw32.lib, and call it directly as described here[^]
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Managed C++ in VS .NET 2003
|
|
|
|
|
|
Hello everyone
I need an algorythm to save paths to every leaf in a binary search tree. I'm saving the path in a 2D array (one field for name of the leaf, the other for steps in the tree - 1,0,2).
Anyone has an example of such algorytm, or can tell me how to work on it. I'm a beginner and i dont know much about C++ or programming in general.
Help me please.
|
|
|
|