|
pix_programmer wrote: error C3767: 'System::Security::AccessControl::ObjectSecurity::WriteUnlock': candidate function(s) not accessible
You are trying to access a protected method. WriteUnlock() is a protected method and won't be accessible from outside the class.
pix_programmer wrote: While creating installer for this application, this works fine under Win XP. But did not work with Windows 7. There I've to manually set Full Control to the file.
From Vista onwards, you need to utilize the program data folders to write information like this. You will have full write access to these folders.
pix_programmer wrote: How to set access control from C++/CLI
Look at the MSDN documentation[^] for SetAccessControl() method.
Best wishes,
Navaneeth
|
|
|
|
|
Hi all,
I'm working on a user control which is basicly a customized edit control (HexEditBox).
It has a context menu which is activated by the right mouse click, as per normal.
All is working fine with the control, but has a visual aspect that I'm not happy with.
When the context menu is activated the caret is hidden from the control.
For most of the menu items this is irrelevant, but for the paste option the user looses
visual indication where the paste will occur.
It is anyway possible the prevent the context menu from hiding the controls caret?
Thanks in advance .. Milton
|
|
|
|
|
|
I have a C# method declared as:
public static bool MethodName(double [] d1,....)
and am try to call it from a C++ mixed mode method. I have tried to to so as follows:
array<double ^,="" 1=""> ^d = gcnew array<double ^,="" 1="">(2);
d[0] = gcnew double
d[1] = gcnew double
d[0] = 1.0;
d[1] = 2.0;
classname::MethodName(d);
I get a compler error saying cannot convert param 1 from cli::array<type, dimmension=""> ^ to cli::array<Type, dimmension> ^
Does anyone have any ideas on how to correctly pass an arry from C++ to c#?
|
|
|
|
|
The array does not indicate the type of object in the array. So, I would allocate it like this:
array<double>^ d = gcnew array<double>(2);
d[0] = 1.0;
d[1] = 2.0;
MethodTakingDoubleArray(d);
John
|
|
|
|
|
Thanks. I actually just figured it out myself also. Do you by any chance know how to pass a double from C++ to C# as an out parameter?
|
|
|
|
|
Sure, that should be no problem. I just tried this.
C++/CLI side:
double val = 1.0;
CSharpObj->ChangeInCSharp(val);
Debug::WriteLine(val);
C# side:
public void ChangeInCSharp(out double changeme)
{
changeme = 4.0;
}
John
|
|
|
|
|
Thank you. Now, can you explain why that works to me? I am a very seasoned native C++ and C# developer, but am pretty green to the CLI stuff. an out parameter would normally be passed by reference, but the way that this is being called seems to be by value.
|
|
|
|
|
It's all in the metadata of the method signature written by the C# compiler. When C++/CLI compiler resolves the call, it sees the IL Metadata indicating that the parameter is 'out'. So, the C++/CLI compiler knows to generate calling code with the value passed by reference. I haven't looked at the generated IL but it's also possible that the double is boxed when passed as an out parameter.
John
|
|
|
|
|
Thank you. I love "automagic" code.
|
|
|
|
|
This bothered me a little at first too but then it was pointed out that it's not too different than standard C++ pass-by-reference.
int x = 5;
DoSomething(x);
Without examining the declaration of DoSomething() there's no indication at the calling site whether it's pass by value or by reference. The usual hidden C++ magic. Of course, intellisense helps some unless you're using C++/CLI...oh wait we are I use Visual Assist which helps sometimes.
John
|
|
|
|
|
Hi all, I am trying to get assembly sersion of my app and display on aboutform for user to know what version of software they are running.
thanks
|
|
|
|
|
You already posted this question in the C# forum, and received a number of answers. If you have supplementary questions then post then in the original thread.
I must get a clever new signature for 2011.
|
|
|
|
|
yes you are right. I got that working too. but there is a differences between C++/CLI and C# version of the code. In C# (VS2010) you have form called AboutBox which is prebuild with all of the information. In C++/CLI you do not have it. I am sorry if I confuesd you.
thanks,
|
|
|
|
|
jashimu wrote: In C# (VS2010) you have form called AboutBox which is prebuild with all of the information. In C++/CLI you do not have it.
That is nothing to do with the question you are asking.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi!
I've to get the OS Name. I'm using the following code:
OSVERSIONINFOEX *osName = new OSVERSIONINFOEX();
System::Console::Write(osName->dwMinorVersion.ToString());
It only prints "0". I need the output as a Text like "Windows XP". I want to check whether Windows 7 or Vista is installed on a particular machine? How to do this using C++/CLI?
modified on Wednesday, March 2, 2011 8:11 AM
|
|
|
|
|
pix_programmer wrote: it only prints "0".
That's what you told it to do.
I would suggest you consult the details here[^] on MSDN for the different values that explain which version of the operating system you are running on.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi!
I've used the following code to check whether Windows 7 is installed in a particular system.
OSVERSIONINFOEX *osName = new OSVERSIONINFOEX();
if ( osName->dwMajorVersion == 6 )
{
if( osName->dwMinorVersion == 0 )
{
if( osName->wProductType == VER_NT_WORKSTATION )
{
System::Console::Write("Windows Vista is installed in this computer");
}
else
{
System::Console::Write("Windows Server 2008 is installed in this computer");
}
}
if ( osName->dwMinorVersion == 1 )
{
if( osName->wProductType == VER_NT_WORKSTATION )
{
System::Console::Write("Windows 7 is installed in this computer");
}
else
{
System::Console::Write("Windows Server 2008 R2 is installed in this computer");
}
}
}
else
System::Console::Write("Windows XP is installed in this computer");
But it always prints "Windows XP is installed in this computer" in a Windows 7 System also. How to find the OS Name in a System?
|
|
|
|
|
I'm not surprised, since you have not initialised your OSVERSIONINFOEX structure with any values. Take a look here[^] for details on what you are supposed to do.
I must get a clever new signature for 2011.
|
|
|
|
|
I have a Database Class which gets created on the CLR heap using gcnew. The problem is that the database connection is made in the constructor of the database class. What I need to do is deallocate the database object early if the connection to the database is lost and then recreate the object on the CLR heap. My question is can memory allocated with gcnew be deallocated before the garbage collector deallocates it using the delete operator?
|
|
|
|
|
John Robert Wilk wrote: My question is can memory allocated with gcnew be deallocated before the garbage collector deallocates it using the delete operator No. delete on a managed object won't remove the instance from CLI heap. All it does is call the destructor of the object. GC will reclaim the memory later.
You can cleanup the resources that you have used, like connection object or any other native handles deterministically. But the object will be deallocated only by garbage collector. On a garbage collected environment, you don't have to worry about cleaning up the memory allocated. All you have to ensure is no strong references exists to the object that will prevent GC from collecting.
For cleaning the resources, C++/CLI provides methods like "Stack semantics". In which the compiler implements IDisposable on the type and create code to call Dispose() method when the scope ends. You can write your cleanup code inside the Dispose() method. This is the recommended way of cleaning up managed objects. For native objects, you have to call delete on them.
John Robert Wilk wrote: The problem is that the database connection is made in the constructor of the database class Usual pattern for database access is, opening connection, executing query and closing the connection. ADO.NET has connection pooling built in and connection instances are created from there. Unless you have a good reason for initializing the connection on the constructor, the pattern explained should be followed.
Best wishes,
Navaneeth
|
|
|
|
|
|
Hi!
Is there an equivalent for MSXML.XMLHTTPRequest(VB) in C++/CLI? I've to send an XML Text to a server. How to do this using C++/CLI?
|
|
|
|
|
You can use the WebRequest[^] class.
Best wishes,
Navaneeth
|
|
|
|
|
Hi!
I used the following code. It only prints "OK". But I want to send an XML text to the server and also downlod from the server. This is the code:
<br />
WebRequest^ request = WebRequest::Create( "https://live.play368.com/cgibin/EClientIntegration" );<br />
request->Credentials = CredentialCache::DefaultCredentials;<br />
HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse());<br />
Console::WriteLine( response->StatusDescription );<br />
System::String^ Dsc = response->StatusDescription;<br />
Stream^ dataStream = response->GetResponseStream();<br />
StreamReader^ reader = gcnew StreamReader( dataStream );<br />
String^ responseFromServer = reader->ReadToEnd();<br />
Console::WriteLine( responseFromServer );<br />
reader->Close();<br />
dataStream->Close();<br />
response->Close();<br />
What else need to be done to send XML text to the server and download from server?
|
|
|
|