|
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:
|
|
|
|
|
when I added a report to my project, then packaged it.
On the client computer, I installed .NET Framework, then installed MDac2.7, finally installed my project, but when view the report, it's go to error!
maybe it's the license problem.
how can I solve this?
|
|
|
|
|
Crystal Report framework is different from .net framework and MDac. Go and see the CD that you used to installed .NET framework.(I guess its CD No.5 of Visual Studio.NET). You will see a separate directory that included Crystal Report Framework.
Mazy
No sig. available now.
|
|
|
|
|
hi,
thanks for your reply.
But I dinnot find any folder of your mean. Just thought when used Crystal Reports in our project, the setup project will detect the component of Crystal Reports and include it while you setup.
Would you show me the Crystal Report Framework folder or something like a file to setup CR Framework.
thanks again.
|
|
|
|
|
hi friends,
I am currently interested in writing a packet capture program like etheral. I finished the base api part. I used packet.dll source code of winpcap and ported all the function to c#. In other way , my api class doesn't use wpcap.dll and packetx.dll. i only use npf.sys ndis kernel driver. And then i downloaded etheral source code and added the ability of supporting over 15 protocols which are LLC , NETBIOS , IPX , STP , CDP , TCP , UDP , ICMP , HTTP , NBSS , NBDS , NBNS , ARP , EIGRP , DNS ( Not finished yet ) , LOOPBACK , SMB ( Not finished yet ) and SMB Mail SLot ( Not finished yet ).
Because it is very difficult to add so many protocols to my project and because it takes so much time, i need friends to help the project finished and to correct my bugs in the code and to recommend better methods that can be used in the code.
thanks for now,
sincerely yours,
Fırat Koçak
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
i have been given what seems like an imposible task of trying to read in an old random access file generated by VB6.. i have to parse out a ton of values out of this file, and to be honest i have no clue on if this is even possible..
here is what im doing currently:
FileStream aFile = new FileStream(m_strReportFilename, FileMode.Open);
byData = new byte[2];
aFile.Read(byData, 0, byData.Length);
int nInt = Convert.ToInt32(byData); this crashes on the last line with the error 'Specified cast is not valid '..
i have a listing of the structure of the file which consists of the following types: Integer , String (of set length), Currency (which is not a type in .NET), Boolean , and Date ..
i had it where i read in the whole file into a byte array to parse, but now im trying to just get the first integer out of the file.. can someone point me in the right direction please?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
hi,
i couldn't see any function call as you made. There is no any ToInt32 function accepting a byte array as a parameter. But i can suggest you a few way to do this.
But first you should correct the array length of byData to the value 4 ( for int values there needs a 4-byte space ).
Way 1 -
unsafe public static int AddressOf(byte[] variable)
{
int ptrptr;
fixed(byte* ptr = variable)
{ptrptr = (int) ptr;}
return ptrptr;
}
int byDataAddr = AddressOf( byData );
int * iValue = ( int * ) byDataAddr;
int nInt = *iValue;
Way 2 -
int nInt = ( ( int ) byData[3] ) << 24 + ( ( int ) byData[2] ) << 16 +
( ( int ) byData[1] ) << 8 + ( int ) byData[0];
there is a way more but not so important. those above may help you, i hope
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
thanks for the suggestion, i will try what you have suggested.. according to what ive been told an int in .net is 4 bytes, but in vb6 an int is 2 bytes, let me know if im mistaken.
thanks for the help, ill let you know how it goes!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
this has helped a bit with integers, but im having a hard time seeing how i would use either of these methods to read strings or bools, any suggestions?
thanks in advance!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
way #1 - works, but is unsafe
way #2 - does not give correct values, i changed it to what is listed below since the Integers im reading are 2 bytes
int nInt = ( ( int ) byData[1] ) << 8 + ( int ) byData[0]; any suggestions on how to get the correct value without being 'unsafe', and how to parse other types such as strings, dates, and booleans?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
without being 'unsafe'
unsafe only if used incorrectly. What u have works, thus is cant be unsafe in a danger sense.
dazinith wrote:
how to parse other types such as strings, dates, and booleans?
Have a look at the Encoder classes as well as the Convert class.
A good knowledge of how types are allocated in VB would also help in your case.
<a TITLE="See my user info" href=http:
|
|
|
|
|
way - 1 : it may be unsafe. but unsafe doesn't mean that it is really unsafe . it means that "be carefulu on using unsafe, if you incorrectly use it you may crash the system LOL ). bu if you want your code pure Managed then you are wright.
way - 2 : When you wrote an int value to a file or a memory it is written as fallows,
first low part of the value and then the high part.
2 bytes value (byte0-byte1) byte1 and then byte2
4 bytes value (byte0-byte1-byte2-byte3) byte3 and then byte2 and then byte1 and latest byte0
So you must know the layout of the value of the byte array you try to read from a file. so lıater you can write the function below to read different types of value from a byte array
public static bool GetBool( byte [] MyData , int index )
{
return ( MyData[ index ] == 0 ? false : true );
}
public static short GetShort( byte [] MyData , int index )
{
short s = 0;
s = (short) ( ( ( int ) MyData[ index + 1 ] ) << 8 );
s += (short ) Mydata[ index ];
return s;
}
public static int GetInt( byte [] MyData , int index )
{
int s = 0;
s = ( ( int ) MyData[ index + 3 ] ) << 24;
s = ( ( int ) MyData[ index + 2 ] ) << 16;
s = ( ( int ) MyData[ index + 1 ] ) << 8;
s += ( int ) Mydata[ index ];
return s;
}
public static string GetString( byte [] MyData , int index , int len )
{
string s;
s = Encoding.ASCII.GetString( MyData , index , len );
return s;
}
Before converting date values from a byte array, you must know what format it has. Because i don't know the format, so i cann't help you
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|