|
Hi EveryOne
In VC.NET I added a button control Dynamically
My Code is:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
array<Button^>^ myButton = gcnew array<Button^>(10);
myButton[0]=gcnew Button();
myButton[0]->Location = System::Drawing::Point(300, 189);
myButton[0]->Name = L"button123";
myButton[0]->Size = System::Drawing::Size(148, 41);
myButton[0]->TabIndex = 1;
myButton[0]->Text = L"Added";
myButton[0]->UseVisualStyleBackColor = true;
this->Controls->Add(myButton[0]);
this->button123->Click += gcnew System::EventHandler(this, Form1::button123_Click);
}
But
When I Added the folowing(below) code:
private: System::Void button123_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Verified");
}
and compiled
Then Following Error
form1 doesn't have button123
some body should help me to get rid of this problem
OK....
-- modified at 7:23 Tuesday 20th June, 2006
|
|
|
|
|
Nagaraju_Focus wrote: myButton[0]->Name = L"button123";
The Name property of a control has nothing to do with the name of a variable that the compiler can recognize. Use myButton[0]->Click instead of button123->Click.
Josh
|
|
|
|
|
Thank You
Its working fine
|
|
|
|
|
Hi Every One
i am new to .net programming
in which i am facing problem to accessing database such as
SQLServer
I request kindly send me a procedure for accessing database
OK
Bye...........
G.Nagaraju
G.Nagaraju
|
|
|
|
|
|
If I write a pure C# application, only using the standart publi API, no interop, the same binary should work well on32 bit, 64 bits and perhaps on the compact framework as well if I link against it.
Now how could I achieve the same thing if I do interop and I have a managed C++ API?
let say I have a managed C++ module compiled for 3 different target but with always the same interface:
mycppmodule32.dll
mycppmodule64.dll
mycppmoduleCE.dll
let say in the C# code I also do some interop
internal class User32 // & CE ?!
{
[DllImport("USER32")]
public IntPtr GetHdc(IntPtr hWnd); // 4 byte IntPtr
}
internal class User64 // not sure it exists, but I assume....
{
[DllImport("USER64")]
public IntPtr GetHdc(IntPtr hWnd); // 8 byte IntPtr
}
Let suppose these DLLs are included as modules in my csharpdll.dll.
Now if I deploy all these DLLs, how could write a simple nice code in my C# dll which internally target whatever native lib is appropriate?
Is it possible (to keep it simple)?
|
|
|
|
|
I am new to C# and .Net. I am trying to execute a bat file from inside a C# application. I continue to get a security error and no one here can help me out. Any ideas?
Thanks in advance.
tom
|
|
|
|
|
Don't cross post for a start. You've already had several replies, mine included.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
|
|
|
|
|
Well. I was told here that this may be a .net security issue.
Here is my error message:
Unhandled Exception: System.Security.SecurityException: Request failed.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a
sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur
ityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object ass
emblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle
rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet gran
ts, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Objec
t assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs
, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMet
hodHandle rmh, Assembly asm, SecurityAction action)
at ConsoleApplication_uisftp.HelloWorld.Main()
The action that failed was:
LinkDemand
The type of the first permission that failed was:
System.Security.PermissionSet
The demand was for:
<permissionset class="System.Security.PermissionSet"
version="1"
unrestricted="true">
The granted set of the failing assembly was:
<permissionset class="System.Security.PermissionSet"
version="1">
<ipermission class="System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
read="USERNAME">
<ipermission class="System.Security.Permissions.FileDialogPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
unrestricted="true">
<ipermission class="System.Security.Permissions.FileIOPermission, mscorlib, Vers
ion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
read="R:\C#2\ConsoleApplication uisftp\ConsoleApplication uisftp\bin\Debug\"
pathdiscovery="R:\C#2\ConsoleApplication uisftp\ConsoleApplication uisftp\bin\De
bug\">
<ipermission class="System.Security.Permissions.IsolatedStorageFilePermission, m
scorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
allowed="AssemblyIsolationByUser"
userquota="9223372036854775807"
expiry="9223372036854775807"
permanent="True">
<ipermission class="System.Security.Permissions.ReflectionPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
flags="ReflectionEmit">
<ipermission class="System.Security.Permissions.SecurityPermission, mscorlib, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
flags="Assertion, Execution, BindingRedirects">
<ipermission class="System.Security.Permissions.UIPermission, mscorlib, Version=
2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
unrestricted="true">
<ipermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
url="file:///R:/C#2/ConsoleApplication uisftp/ConsoleApplication uisftp/bin/Debu
g/ConsoleApplication uisftp.exe">
<ipermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib
, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
zone="Intranet">
<ipermission class="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=n
eutral, PublicKeyToken=b77a5c561934e089"
version="1"
unrestricted="true">
<ipermission class="System.Drawing.Printing.PrintingPermission, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
level="DefaultPrinting">
The assembly or AppDomain that failed was:
ConsoleApplication uisftp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
The Zone of the assembly that failed was:
Intranet
The Url of the assembly that failed was:
file:///R:/C#2/ConsoleApplication uisftp/ConsoleApplication uisftp/bin/Debug/Con
soleApplication uisftp.exe
Press any key to continue . . .
|
|
|
|
|
For a start try running it under an admin account if you can, if that succeeds then it's your permissions that are at fault. Otherwise it's something else which I'm not sure of without looking it up.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
|
|
|
|
|
Simple Question: Is it possible to restart the .NET framework to simulate a “cold start?” (I.E. similar to restarting your computer and inheritly the framework without restarting your computer.)
If this is possible, how does one accomplish this?
Thank you,
Frank V.
www.TheOpenSourceU.com
|
|
|
|
|
You can't. The Framework is only a set of DLL.
My Blog
|
|
|
|
|
I think that you are correct. You can't. But the framework is more than just DLLs. There is an engine that runs to compile these apps. The 'DLLs' are loaded in to memory (by the engine) and then used through the use of the session. (Until the computer turns off).
I'm looking to unload all of the dlls from memory. And again, I think you are right. you simply cant without restarting and flushing the memory...
Thanks for your response!
Frank V.
http://www.TheOpenSourceU.com
|
|
|
|
|
The .NET framework exists in any process which is running managed code. "Restarting" the framework basically means killing the process and rerunning the managed app.
Josh
|
|
|
|
|
Stop all managed Apps & restart any one of them!
|
|
|
|
|
Why do you want to "cold start .NET Framework"?
Best,
Jun
|
|
|
|
|
I need to simulte a fresh boot cycle (and am trying to save time) so that I can test performance of an application that will only be ran once the computer starts up. Hence, inital load time is important.
Thank you,
Frank V.
|
|
|
|
|
Jawz-X wrote: I need to simulte a fresh boot cycle
An interesting idea, but I am not aware of any such approaches.
Best,
Jun
|
|
|
|
|
Hi,
How would you add a reference to microsoft.xml namespace?? I tried using imports and it comes back with
imports microsoft.visual basic - not giving XML choice?
Many thanks.
|
|
|
|
|
There is no Microsoft.Xml namespace, it's System.Xml.
You have to add a reference to the .DLL file that the namespace resides in. In the Solution Explorer, right-click the References folder, then click on Add Reference. In the dialog that comes up, make sure the .NET tab is selected, then scroll down the list and find System.Xml. Double click it and you've added the reference to your project. Then you can add
Imports System.Xml
at the top of your code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
When trying to write to the windows application log the following (vb.net code) works great on 2000 and XP but not on Vista:
Dim ev As New EventLog("Application", System.Environment.MachineName, "MyProgramName")
Dim LogText As String = "Hello world"
Dim EntryType As System.Diagnostics.EventLogEntryType = EventLogEntryType.Information
ev.WriteEntry(LogText, EntryType, LogEventID)
ev.Close()
What happens is the following excpetion is thrown on Vista:
System.Security.SecurityException: The source was not found, but some or
all event logs could not be searched. Inaccessible logs: Security.
at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName,
String currentMachineName)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)
Can anyone offer any ideas on what extra is needed for Vista?
Thanks very much in advance for your help,
Rob
|
|
|
|
|
|
Thank you - that turned out to be the problem, however ...
When I tried to create the "source" in Vista I got another error:
"The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security."
I got around this by changing the compatibility properties on my exe file to give it Administrator rights.
However, this in turn led to a pesky Vista warning pop-up box each time my program started up.
Next I deleted the source and then tried to create it in my program by writing the reg key entry myself.
Dim Reg As Microsoft.Win32.Registry
Dim RegKey As Microsoft.Win32.RegistryKey
RegKey = Reg.LocalMachine.CreateSubKey("SYSTEM\CurrentControlSet\Services\EventLog\Application")
RegKey.SetValue("MyProgramName", "")
RegKey.Close()
I found that if I did it this way, and on the exe file removed the admin rights and changed the properties - security - users - advanced - users - edit - to full control
then everything worked ok and I didn't get the pesky Vista warnings every time I started the program.
Any advice on the advisability of one approach over the other?
Thanks, Rob
|
|
|
|
|
|
Thanks for this, but wow is it ever complicated ...
Do you know of an example somewhere where I might be able to better see how these pieces fit together - honestly after reading thru the write ups linked above and (unsuccessfully trying a few things in my code) I am more lost then when I begun.
Also, although I want access to write event log entries, I also need registry access to apply a hook into IE (that will let my clients dial a phone number right out of IE).
All this seems to work if I simply update the permissions on Vista to allow full access; I understand where it would be good to further limit these so any further support - and patience you can extend would be great.
Again, maybe a pointer to an example ....
Best Regards
Rob
www.callclerk.com
|
|
|
|
|