|
Private Shared m_vb6FormDefInstance As Form1<br />
Private Shared m_InitializingDefInstance As Boolean<br />
Public Shared Property DefInstance() As Form1<br />
Get<br />
If m_vb6FormDefInstance Is Nothing _<br />
OrElse m_vb6FormDefInstance.IsDisposed Then<br />
m_InitializingDefInstance = True<br />
m_vb6FormDefInstance = New Form1()<br />
m_InitializingDefInstance = False<br />
End If<br />
DefInstance = m_vb6FormDefInstance<br />
End Get<br />
Set(ByVal Value As Form1)<br />
m_vb6FormDefInstance = Value<br />
End Set<br />
End Property
Can anyone convert the code snippet for me into C# code.
|
|
|
|
|
private static Form1 formDefInstance;
private static bool initializingDefInstance;
public static Form1 DefInstance
{
get
{
if(formDefInstance == null || formDefInstance.IsDisposed)
{
initializingDefInstance = true;
formDefInstance = new Form1();
initializingDefInstance = false;
}
return formDefInstance;
}
set
{
formDefInstance = value;
}
}
This is the wrong way to initialize a Singleton Form. No locking is provided to ensure that two threads dont both create an instance of your form1 class.
|
|
|
|
|
Flawless !
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
|
|
|
|
|
I have been developing an Outlook Addin (2003) with VS2003 C#. It has been working very well until last week when running it in debug, Outlook starts and then stops. An error is reported in the Application log "Accepted Safe Mode action : Microsoft Office Outlook." Outlook stops and so does VS no exceptions are fires even with every debug trap set on. When Outlook next runs it asks if the Addin should be de-activated.
I created a new addin project from the project template wizard with no functionality except the connect class and this does exactly the same.
Any help would be most appreciated as I can only debug it run mode using messages.
|
|
|
|
|
As is well known, the code in C# assembly is not protected and anybody can see that and can even be decompiled and recompiled after some changes.
The obfuscators are not of much help as I found that code is still visible albeit in some obscure form and even here decompilation and recompilation is possible.
After some search, I found that Salamander's .NET Protector which claims that the code cannot even be seen and cannot be recompiled after decompilation. Their claim is that they are converting the code to the native code and therefore the code cannot be seen again. Due to their high pricing, it is essential to know whether this product is really useful as claimed.
Can the esteemed developers at this site enlighten me about the usefulness of this product if anybody has used this product? Is the said product worth using for protecting one's C# assembly?
As this question is of great importance for a C# developer interested in protecting his code prepared after lots of efforts, help in this regard will be highly appreciated.
Regards,
|
|
|
|
|
Two things:
:: Once the code is compiled you can never ever get the original code back from the compiled code. What you can do is to recreate code that will do the same thing, but that is not the original C# code.
:: There is no way to completely protect the code from reverse engineering. If the code is executeable in any form, it is also possible to read. Obfuscators only make it harder to read the code.
Also:
If you use something like Salamander's .NET Protector that compiles the code to native code, you lose the dynamic compilation. That means that the code is compiled for a generic processor rather than the specific processor that will run the code. As it will not be able to use any special instructions that are not present in all processors, the code will run more slowly on some systems.
You have to weight this against what you feel that you gain by making it harder to read the code.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
is there a way to check if the latest Windows Updates are installed on a specified computer?
Thanks for your help!
|
|
|
|
|
You could probably mash something together using the Windows Update Agent API[^]. I don't think you'll find alot of examples though. This is an API that doesn't get much use outside of Automatic Updates in 2000/XP/2003.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi there
I am trying to create a software package in C# and need to connect it to a PIC microchip programmer that i have created using the serial port. Does any one know how i can implement serial communication in C#?
THANKS
|
|
|
|
|
How are you my friend ?
You can Do that By two ways .
The first Way is to use predefined Package Dll as Tapi32.dll it is dll found in your system32 of your windows Os designed for digital telephony applications and serial programming But i see that you are not trying to communicate via your modem so the second way will work with you
2- Sovage Innovacations:
For Serial Programming you can download their program which Enables you to communicate via Ports and write on Chips Like MicroControllers and others
And there are alot of useful links to other websites interested in serial programming at this website here is the site
http://www.oopic.com
Especially in robotics Designing.
Miss With The Best And Die Like The Rest
|
|
|
|
|
hi there...thanks for the answer...i am doing well..
yup am not communicating with modems...so cant use the first method...the problem with the second method is that i have to create my own software package as part of a project and cannot use an already made program and software therefore i have to implement the serial communication in my own software and for that i require help.i dnt see any built in librares for serial communication and am not sure hot to go about doing that..
thanks
|
|
|
|
|
Try this. I used it a while ago to good effect
|
|
|
|
|
It does help if you include a reference doesn't it ! Sorry
http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/
|
|
|
|
|
sevenacross wrote:
It does help if you include a reference doesn't it ! Sorry
http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/
hi thanks for the reply
I did look at this piece on the article link that you pasted but isnt that visual basic that they are explaining there? I am looking for something in C#. I am not sure where to start in that code either. maybe you can advice. what do i include as well? using System.....
Thanks
|
|
|
|
|
I just referenced the commbase.dll and added using JH.CommBase. Then inherited from CommLine and hooked into the NewLineCallback event which gave me a callback every time a new line was received. I'm sure that you don't have to take input a line at a time.
|
|
|
|
|
VB.net and C# use the same runtime libraries and are almost entirely interchangable with keyword subsitutions. THere're a number of programs available that do the conversion automatically.
|
|
|
|
|
|
Hi,
In a small Windows Application, I am using UnhandledExceptionEventArgs to trap any UnhandledExceptions and display a friendly messagebox to the user. In this eventhandler, I am just 'eating' off the exceptions to 'Debug.WriteLine()'.
But whatz happening is -- The JITer (JIT Debugger) first traps and tries to debug the exception and only on click of Cancel for JITer prompt, my messagebox comes up.
How to disable this debugging prompt? The Windows application should not get wired up to any debugger.
Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
Crystal reports doesn't support MySql for reporting, is there some reporting tool that does? I have to use it througgh .NET with MySql...
Thanks in Advance...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
This is a C# 2005 Problem:
I have an MDIForm and 5 child forms in my project. what i have to do is, during MDI Form's "MdiChildActivate" event I have to set some value to private a variable in my active child form. But when i write a statement like this : this.ActiveMdiChild.childVariableMode="0";
I get an error-"No defination For childVariableMode found in activemdichild". In vb.net i can do this by:
dim a as object
a=me.ActiveMdiChild
a.childVariableMode="0"
But i C# if i do same as VB.NET i get the same error, please solve my problem.I am in very hurry, my whole project is depended on this.
Thanks in Advance.
Sheel
Sheel Gohe
Sheel Gohe
|
|
|
|
|
The best way is to cast ActiveMdiChild down to the class which has the childVariableMode variable. If ActiveMdiChild can be one of several classes, where only some have the variable defined, then your best bet is to declare a base class from which all MDI children derive from and place the childVariableMode variable in the base class.
A quick hack would be to use reflection to do what you want. Simply query for the variables in the object using the variable name ("childVariableMode") and then set the value of the variable.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The ActiveMdiChild property returns a Form object which contains no definition for childVariableMode. To access this variable you have to cast the returned form object to one of your child form types.
Because you don't know which one is currently the active child, you need a way to treat all child form types equally.
One possibility is to define a common base type for all child forms which contains the childVariableMode property and then cast the return value of ActiveMdiChild property to this type.
Another way is to define an interface with the childVariableMode which then gets implemented by all child forms and in this case cast the return value of ActiveMdiChild property to interface type.
www.troschuetz.de
|
|
|
|
|
I am writing an interpreter for a language of my own language. It will be basically a command line application. What if I wanted to embed it in a Windows application?
I don't know how to creat a command line application which I can integrate with other windowns form application. CAn anyone help me with any tutorials with that purpose?
AMit
|
|
|
|
|
I don't know if you're expecting the actual command line shell (cmd.exe) to be embedded in an application. If you just want the UI, this[^] might help.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Dear Senthil,
Thanks for your reply. In fact your code is my inspiration. I just don't want a command line interpretor like cmd.exe.
I want a more powerful add-in components. I am trying to write a computational software. My idea is something like this.
>> A=[1,2,3;3,4,5;6,7,8];
output should be displayed in the command prompt
A=[1,2,3;<br />
3,4,5;<br />
6,7,8];
This should define a matrix A .
>>Inverse(A)
this should call function Inverse and display the result from the function Inverse.
So, i want to know how modification I need to make in your code to understand these kind of commands at my command promt in the software.
Regards,
Amit
|
|
|
|