|
Well, if you are display the second form from the first one then you just add a property to the second form.
You can also use a static global (eek.. Yep Global) class with a static property for the data you wish to pass. In most of my current apps, I have a static class called "ApplicationData". It holds any information that will be required by several classes (or forms). It is also where I hold in memory configuration data.
Rocky Moore <><
|
|
|
|
|
Thanks for the reply. This may sound really stupid, but I have just started coding in C#, and dont know how that is done. I thought if I set a global attribute in one class, that I can then call that one from another class. But I cant reference it directly, so was not sure of anyway to do it. But your way sounds good, however, I dont know how to do that. Have you seen any samples on this type of thing?
|
|
|
|
|
Well, in my applications I have a global static class such as:
public class ApplicationData<br />
{<br />
public static string aSharedString=string.Empty;<br />
public static string userName = string.Empty;<br />
public static int user_ID = -1;<br />
public static string currentDocumentName = "RalphyBoy.txt";<br />
}
It can be cleaned up with properties if you like or to add code for locking if thread saftey is a concern.
In my applications, this would have methods to read/write configuration data along with possibly to persist state of an application when required.
It is true that C# does not have any globals but it is also true that they do, it is that you wrap them up in a nice neat class and access the static instance of the class.
Rocky Moore <><
|
|
|
|
|
Using VC,the element events can be get by the following code,how can I get the html element events using c#?
STDMETHODIMP CEventSink::Invoke(DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pdispparams,
VARIANT* pvarResult,
EXCEPINFO* pexcepinfo,
UINT* puArgErr)
{
switch (dispidMember)
{
case DISPID_HTMLELEMENTEVENTS2_ONCLICK:
OnClick();
break;
default:
break;
}
return S_OK;
}
Thanks.;)
|
|
|
|
|
Take a look to this article
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=312
|
|
|
|
|
Thanks a lot.
|
|
|
|
|
Hi,
I know that if you make your applicaton using the Ms Excel 9.0 and automation it will work fine for 2000 and XP versions.
But If I make it using the references to XP, no way to use it in 200O ? isn´t it ?
|
|
|
|
|
No, I don't think so.
You would at the very least have to change the references to point at the mso9.dll etc... and it __might__ still work so long as you're not accesing features in code that don't exist.
|
|
|
|
|
I have a byte[] that contains what in C++ would be this struct:
struct<br />
{<br />
unsigned type : 5;<br />
unsigned level : 2;<br />
unsigned bouncing : 1;<br />
unsigned emp : 1;<br />
unsigned isBomb : 1;<br />
unsigned shrapCount : 5;<br />
unsigned fireType : 1;<br />
};
Is there a way to make the byte[] into a class in C# without doing each member seperately with bitwise AND & shifting?
|
|
|
|
|
You might find the BitVector32 class useful to base your code off of.
You would create references to your types with the following code:
BitVector32 bv = new BitVector32(0);<br />
BitVector32.Section type = BitVector32.CreateSection(31);<br />
BitVector32.Section level = BitVector32.CreateSection(3,type);<br />
BitVector32.Section bouncing = BitVector32.CreateSection(1, level);<br />
BitVector32.Section emp = BitVector32.CreateSection(1, bouncing);<br />
BitVector32.Section isBomb = BitVector32.CreateSection(1, emp);<br />
BitVector32.Section shrapCount = BitVector32.CreateSection(31, isBomb);<br />
BitVector32.Section fireType = BitVector32.CreateSection(1, shrapCount);
The values are accessed as follows:
bv[type] = typeValue;<br />
bv[bouncing] = 1;
Access to your values with no &, |, or <<
|
|
|
|
|
|
for my current c# project i need a ftp connection test.
Given: Username, Password, port, hostname or ip
i tried it with System.Net.Sockets.Socket but it seems to be to slow to test more than 10 ftps in a row, cause of connection delay. the returnvalue just have to be boolean for Online/Offline
Somebody know a fast method to test this?
thanks / regrards
Martin Lierschof
Junior Programming Assistant
World-Direct.at eBussines Solutions GmbH
mail²: martin.lierschof@world-direct.at
|
|
|
|
|
I have an IIS-managed server object, exposed to clients using a service/wellknown web.config entry. But I don't want clients to have to know the type of the object (currently defined in a shared library) -- rather I want them to just query for the interfaces they require. This would theoretically allow me to change the underlying type on the server without code changes on the client.
To achieve this I wanted to expose the type as System.Object, but does not seem to be allowed by the remoting system. Have I made a design mistake? If so, what should I be doing?
Jade Burton
Programmer
|
|
|
|
|
You'll have to expose the object as atleast its interface.
<br />
public IMyInterface GetIt()<br />
{<br />
return (IMyInterface)myObj;<br />
}
where myObj is an object of any class that implements the IMyInterface interface
|
|
|
|
|
You might be able to use internal on all other classes except your facades/interfaces. That should 'hide' those classes from all outside calls.
|
|
|
|
|
If i create an array that is a specific size
int[] myInts = new int[10] but only fill the first 5 values, how can i reduce the length of the array to 5? so the following will happen
myInts[0] = 5;
myInts[1] = 4;
myInts[2] = 3;
myInts[3] = 2;
myInts[4] = 1;
for (int i = 0; i < myInts.Length; i++)
{
Console.WriteLine(myInts[i].ToString());
} and the output would only be 5, 4, 3, 2, 1 and not throw an exception since myInts[5] is null
|
|
|
|
|
hi,
if the size of the array is unknown before it is used then you must check each member of the array for null value.
Change tour for loop to this
for( int i = 0; i < nyInts.Length, myInts[i] != null; i ++ )
as i know there is no any function to resize of an array.
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
If you need to resize an array, you should go throug the ArrayList, even though it isn't typed.
If you need a typed array, but don't know the size of it you can use ArrayList in this way:
<br />
ArrayList al = new ArrayList();<br />
<br />
al.add(5);<br />
al.add(4);<br />
al.add(3);<br />
al.add(2);<br />
al.add(1);<br />
<br />
int[] myInts = (int[])al.ToArray(typeof(int));<br />
If you need to change the size of the array, you can start with ArrayList al = new ArrayList(myInts); instead.
This will add some overhead (going back and forth between arrays and arraylists), but it gives you the type safety you need.
|
|
|
|
|
I want to make a trial version of my program, I want it to expire after 30 days, and if you want more you buy a serial number. (In other words; the usual.)
I know this is a very common thing but I've never done it before, can anyone point me to some tutorials or something about how to do this? I'm thinking I can make a win32 C++ dll and interop with it to avoid being easily decompiled, but I don't know how to get started with the s/n and expiration stuff.
Thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Bog wrote:
I want to make a trial version of my program, I want it to expire after 30 days, and if you want more you buy a serial number. (In other words; the usual.)
I know this is a very common thing but I've never done it before, can anyone point me to some tutorials or something about how to do this? I'm thinking I can make a win32 C++ dll and interop with it to avoid being easily decompiled, but I don't know how to get started with the s/n and expiration stuff.
Sorry for not giving a solution to you: I think you won't have an easy solution. Protection schemes that use a separate DLL are simply not safe. What one normally needs to do is to create a dummy DLL and provide the application with it. Anyone capable of decompiling an app should be capable of creating such a DLL.
I too am looking for a good protection scheme for .NET but I was not able to find such a thing yet, even with hard locks involved.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
A possible solution: encrypt the serial number with an asymmetric algorithm.
Even after decompilation, people will find the public key needed to decrypt the serial number but they will not find the private key needed to crypt it.
|
|
|
|
|
I've had this issue before.
Unless you want to pay out loads of cash for a protection package which will almost certainly get cracked you should just put some simple time expiry code in. Maybe add a time stamp to an innocent file somewhere or something.
The thing is in my experience, if you produce a nice little app and distribute it as a trial then get people to buy. Most people will- if it is a good application- pay the few quid to get the full version. The issue really is that if it is an app that is __so__ good that it becomes __very__ popular, it doesn't matter what scheme people use to protect it, it WILL be cracked and on Kazaa within 24 hours. (as with Windows XP, Office XP, PhotoShop, InDesign etc etc etc all cracked and shared despite the investment in copy protection and license enforcement!)
You can't win.
The only 98% way of securing the software is to use something like hardware dongling... but that's a different set of deployment scenarios.
|
|
|
|
|
|
I agree. Don't waste too much time in developing some "secure" serial number/trial version scheme. Better to spend that time making your application better. If companies like Microsoft, Adobe and Macromedia can't stop cracking/hacking, what chance do we have? If your software is any good it WILL be cracked one way or another.
-----------------------------
Try my Batch Image Processing Software Read my DirectX 8 Tutorials
|
|
|
|
|
The best protection I have seen was for Virtual TurnTables. If you tried to debug the exe, it would simply shutdown your system. But even that wont stop the crackers.
<a TITLE="See my user info" href=http:
|
|
|
|