|
Thank you, this is what I am about to implement. I've just hoped that there is already implemented bidirectional up-to-date for changes iterator.
|
|
|
|
|
Hello,
I am trying to implement drag within my shell namespace extension. I noticed that in MFC you are able to set up a message area to attach to the events such as OnBeginDrag.
My question is; How do I attach to those events using c#?
Thank you,
Rick
Rick
Rick
|
|
|
|
|
They hide that information in the Documentation[^]
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Yes,
I get that part about the event, but How do i attach to an event that is sent by the windows shell.
Rick
|
|
|
|
|
Rick, with a little Googling i found this CodeProject Article[^] maybe it will help
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
hi,
i would like to make a serial communication with an antenna to send and recieve data from another antenna, the first one is connected on a com port of my pc. i program it in visual studio 2003
but i dont know how to start
does anybody know a site with samples that could help me?
thxx
|
|
|
|
|
serial communications are much easier using the provided System.Ports.Serial class in VS05. IF you're unable to use the (free) express edition of 05, there are several user written libraries available on this site if you use the search function.
|
|
|
|
|
Hello
To access any port -Serial, LPT, USB, etc...- or device -eg. modem- in C3 you follow these steps:
1- Call Windows API CreateFile() function with the device name as the filename. ie. CreateFile("COM1") for example.
2- Get The handle of the created file.
3- Supply that handle to the constructor of a FileStream object.
4- Use that FileStream object to read and write from/to the port/device.
And no, you can't construct a FileStream from the port directly. Sorry!
Regards
|
|
|
|
|
I'm trying to open a database connection via my app.config file however my connection string keeps coming back as NULL.
Here's my app.config file:
----------------------------------
<connectionStrings>
<add name="DBConn" connectionString="Data Source = myDataSource;Initial Catalog = catalogName;User Id =myUserId;Password = myPword;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
-------------------------------------
Here's the code I'm using to open my connection. The "settings" variable keeps coming back as null:
---------------------------------------
string cnString = null;
// Look for the name in the connectionStrings section.
ConnectionStringSettings settings =
ConfigurationManager.ConnectionStrings["DBConn"];
// If found, return the connection string.
if (settings != null)
cnString = settings.ConnectionString;
connection = new SqlConnection(cnString);
connection.Open();
------------------------------------------------
Do I perhaps have my app.config in the wrong location? I placed it in the root directory of my project (located alongside my project and ".cs" file).
Thanks in advance.
-Goalie35
|
|
|
|
|
Looks ok to me!
Have you got the <connectionStrings> under <configuration> (where it should be) and not in the app settings or something like that?
Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob. Thanks for replying.
My full app.config looks like the following:
-------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="ReportDBConn"
connectionString="Data Source = myConnectionString;Initial Catalog = catalogName;User Id =myuserId;Password = myPword;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
---------------------------------------------------
Thanks again.
-Goalie35
|
|
|
|
|
Are you able to see <yourexename>.app.config in the bin/Debug (or Release) directory? Did you add your app.config manually or through the Add Items menu in VS .NET? If it's the former, then VS .NET doesn't generate exename.app.config automatically.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi
How does .NET split the command line arguments to generate the args[] array?
Does it just to a string.Split(fullCommandLine, ' ') ?
If yes, will this code be correct to complely restore the full command line?
string parameters = "";
foreach (string s in args)
{
parameters += " " + s;
}
parameters.TrimEnd(' ');
The reason behind is this question is that I have to use the complete command line, because I parse a parameter that uses a file path like -file="C:\Documents and Settings"
This will be split by .NET. In C++ we had a lpCommandLine which contained the complete command line. Does my loop do the same thing?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
yes it is but you should replace parameters.TrimEnd(' '); by parameters=parameters.trim();
|
|
|
|
|
Okay thanks.
I wanted to edit my post to change it to "Trim", but the operation always fails with an error message. I hate this server
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If you want the complete command line use Environment.CommandLine .
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Yeah, but this also includes the executable path.
So either I remove that one or use my loop, makes not much difference
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
In my c++ code, I have a struct which has a dynamically allocated array. Now in c# code, I want to declare the same struct in a proper way so that I can call c++ native code from c#.
If in C++ I have the following:
struct A {
int * arrInt;
};
typedef struct A A_STRUCT;
void func(A_STRUCT * ptrStruct);
How would I declare the struct in c# and also how to define the function "prototype" when doing dllimport? Thanks a lot.
|
|
|
|
|
Can somebody give me an idea of how to build multipage dynamically without having it created at design time at all??
rmr
|
|
|
|
|
a multipage (though i haven't used one yet ) is a class as every other designable object in .net. I guess you're talking about creating a multipage in the codeeditor, don't you? If so, you just have to declare a multipage object and assign a new instance of the multipage class to it. that could look like
<br />
MultiPage mymultipage = new MultiPage();<br />
If you want to add controls (Multipage sounds similar to a form ) you will have to use its methods. To access all public multipage members just go on and type
<br />
mymultipage.MEMBER_OF_MULTIPAGE_CLASS<br />
in reality you could do it like this:
<br />
mymultipage.BackColor = System.Colors.Black;<br />
If you don't know much about classes and object oriented programming (oop) you should first read some stuff about it. Since I started writing vb.net and then wrote some php and cpp too, i have inherited some knowledge about c#. thats why i cant recommend you a special tutorial but maybe someone else can
good luck,
mik
|
|
|
|
|
Thanks.
Actually, am trying to use the Tabstrip control with the multipage control.
Am able to bind data to a Tabstrip dynamically when tabstrip and multipage are created at design time. But, am not able to create multipage at run time.
Microsoft.Web.UI.WebControls.MultiPage multipage1 = new Microsoft.Web.UI.WebControls.MultiPage();
Please help me on this.
rmr
|
|
|
|
|
Hi,
I'm completly new to the topic of Remoting in .NET and I have a few questions to find out if this technology is suitable for the needs of my application.
I want to create an application which runs on several different hosts, which work together as if they where one application. The data which have to be given from one object to the next one (or from one host to the next one, where the difference shouldn't matter) is an XML file which is stored in an object of the type XmlDocument. As far as I know this class does not implement the ISerializeable interface. So I would like to know if there is any way to process an instance of there class through the Remoting?
My second question is about the objects which methods are called remotely. I've read some tutorials, but they all take about creating the object at the client. I want to create the object on the server maschines and enable the clients to use these objects by reference. In detail I've created a design where every component looks the same at the outside (they extend the same class). Every host will have an instance of a class which extends this basic class. A client will know decide to which server the data has to be send and call the methods of the object on the specific server. As the initialization process is quite difficult in some cases (as there may be several other "stations" behind the remote objects) I would like to initialize all objects when the server starts. I've read about Server Activated Objects which could by the best solution, but in this case the object will be created when the first client accesses it. Isn't there any way I can make an already initialized ojbect available to all clients?
I'm sorry for the long text, but as I'm new to the topic I wanted to explain everything.
Thank you very much for reading and maybe for some answers!
Stampede
|
|
|
|
|
Hi.
My Goal is: to push the world such that future .NET hashcode concept uses more bit's.
My Question is: where do i have to push?
I think i understand the HashCode concept, and wanted to use it with Hashtable. but it seems the C#/.Net implementation of that concept is bullshit.
First collision of hashcode occured with my 8th element i wanted to insert. (ofc my GetHashCode was bad, using String.GetHashCode())
then i wrote the best possible GetHashCode(); algorithm i could think of.
but on 30'000 elements, again: Collision! (2 different elements with same hashcode).
with "birthday-attack" (which is unfortunatly happening in my code, even if i didnt want that).
you will have a collision each about 65536 elements. 2^(32bit/2)
and i wouldnt like 64 bits, thats bit short.
128 bits? that would be great! but in some years you will be able to create collisions.
so lets use 256 bits, thats what i dream of
Regards,
Random_zh
btw here the implementation of GetHashCode of my ArrayList,
it could be very useful for some others:
i hope i made good choices on RSA numbers, and no mistakes ^^
oh yea GetLargeHashCode() is part of my 64 bit LargeHashtable, i'm currently implementing.
no more collisions and nearly same speed as Hashtable
<code>
public override int GetHashCode()
{
int result = 0;
for (int i = 0; i < Count; i++)
{
result = result ^ Encrypt((int) this[i]);
}
return result;
}
/// <summary>
/// GetLargeHashCode
/// </summary>
/// <returns>int[2]</returns>
public int[] GetLargeHashCode()
{
int[] result = new int[2];
for (int i = 0; i < Count; i++)
{
result[i%2] = result[(i+1)%2] ^ Encrypt((int) this[i]); // remember: ^ is XOR
}
return result;
}
/// <summary>
/// using RSA http://en.wikipedia.org/wiki/Rsa
/// be aware of the birthday attack http://en.wikipedia.org/wiki/Birthday_attack
///
/// with those parameters, Encrypt maps following integer ranges to integer ranges:
/// -2147483648 = int.MinValue -------> 0
/// -2147483647 = int.MinValue+1 -------> 1
/// ...
/// -2147483640 = int.MinValue+8 -------> pow(7,11)=1977326743
/// ... from -2147483640 to 2147483416 -------> very good hash (in this range UNIQUE) for each number in this range. This range contains 99.999994% of all int numbers.
/// 2147483416=p*q-int.MaxValue-8 -------> -pow(7,11)-225 = -1977326968
/// ...
/// 2147483423=p*q-int.MaxValue-1 -------> 0
/// 2147483424=p*q-int.MaxValue -------> 1
/// ...
/// from here it starts repeating the sequence.
/// All bad ranges together contain only 225+8+8 = 241 numbers and are on the negative and positive end.
///
/// p = 65551 prime
/// q = 65521 prime
/// n = p * q // uint.MaxValue-n = 225! thats small =)
/// e = 31; OR e = 11; // 11 is not much weaker, but 3times faster // NEVER try e=1,2,3,4,5,6,7,8,9,10 or such things, check gcd(d,e)==1
/// d = (p - 1) * (q - 1)
/// gcd(d, e) == 1;
/// </summary>
/// <param name="theM">number</param>
/// <returns>'encrypted' number or hash of number</returns>
public int Encrypt(int theM)
{
const int e = 11;
const uint n = 4294967071;
uint m = (uint) theM + (uint) int.MaxValue + 1;
ulong multiplyMod = m;
// the first for-loop is already square
for (int i = 2; i <= e; i++)
{
multiplyMod = multiplyMod * m % n;
}
return (int) multiplyMod;
}
</code>
-- modified at 12:12 Thursday 7th September, 2006 (updated code)
|
|
|
|
|
Hardcoded values, are you serious?
Why don't you just use the SHA (256, 384, 2048, ...) as hash function?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
coz i forgot to think about sha may be.
and coz it would not solve my problem.
and i needed to hack it fast.
if you used any sha or md5 shortened to integer as Hashtable needs it, you would also find lot of numbers(or elements) with collisions.
i will have to search (and if not exists make) a Hastable accepting keys with more then 32 bits, and i will have to have lots of GetHashCode methods with more than 32 bits for that, for expample with SHA.
regards
EDIT:
no, i decided that using SHA wouldnt be faster than 10 ulong multiplications. (see code)
and my code now generates less collisions than if i had used sha. (if you build my 64bit hash from 2 integers, you will only find 50'625 collisions from 2^64 possibilites) (with sha shortened to 64bit you would have (stistical guess): more than 1'000'000'000 collisions between all 2^64 possibilities.)
-- modified at 12:25 Thursday 7th September, 2006
|
|
|
|