|
Judging by the rest of your code, the site you are accessing is something else you've written? If so it looks like that code is sending back an invalid web response.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
I think all the thing I have written....
Can you write a example of proxy with credential in SmartDeviceApplication for me??
thank you !!
|
|
|
|
|
I haven't played with this before so I can't send you any good samples. AFAIK though your client code looks correct. I think that the server/website you are accessing is sending back an invalidly formated HTML page
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
|
I Have a class (not a usercontrol) in a seperate assembly that I need to implement licensing on.
I'd like it to do the following and i'm not sure if this is possible.
a) I'd like to not use LIC files, but instead use a RegistryLicenseProvider which gets a certain key/value from the registry and sees if this is valid. I already have this part in my 'GetLicense' function in my derived LicenseProvider.
b) Developer installs package which creates registry key for RegistryLicenseprovider
which denote that this is a valid 'developer' license. For testing purposes I simply created a registry key with the value 'test'.
now the issue comes in the next steps - it should work like this:
c) When compiling the main exe, the license info gets picked up and embedded as runtime license in the exe
d) Client runs fine without this registry key because if it can't find the registry key it finds it embedded in the exe.
This is how i understand the standard LicFileLicenseProvider to work. Is this correct?
Currently the program runs, but as soon as I delete the registry key the program stops working so obviously nothing is getting embedded. I Had to create my own license.licx file and added it to the project as embedded resource too.
So instead of design time I'd almost need compile time licensing.
What am I forgetting or is this just not possible and should I just forget about this?
Do i need to write my own code that somehow gets the embedded licenses from the calling application?
Thanks
|
|
|
|
|
Side Note: I built the registrylicenseprovider like the one mentioned here:
http://www.codeguru.com/Csharp/.NET/net_framework/licensing/article.php/c5469/
|
|
|
|
|
Hello,
how can i create an array of followig struct:
struct CCDtype
{
double breite;
double höhe;
string btext;
// Konstruktor der Struktur
public CCDtype(double para1, double para2, string para3 )
{ this.breite=para1;
this.höhe =para2;
this.btext =para3;
}
} ;
I want to initialize it via constructor something like this:
private CCDtype[1] = new CCDtype[] (5.0, 3.7, "1/3\" ( 5.0 x 3.7 mm)");
The Array should be a static member of the struct!
thanks a lot
Daniel
|
|
|
|
|
Try this:
private CCDtype[1] = new CCDtype[] ( new CCDType(5.0, 3.7, "1/3\" ( 5.0 x 3.7 mm)"));
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian,
If I try this, SharpDevelop says "SyntaxError "]" expected. There is something wrong with the empty bracket?
Could you explain me the background of using 2x new pleace?
Daniel
|
|
|
|
|
To create an instance of a class, you need to do this:
MyClass c = new MyClass;
when you create an array, you're in essence creating a lot of class instances. Each one needs to have new called on it, just as it would if you created it on it's own.
I think it's actually
MyClass [] mcArray = { new MyClass(12, "x"), new MyClass(57, "y") }
So, you don't call new on the array, I made a mistake.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks a lot!
At the end a general question:
Is it a good style to deal with a lot of instances of strucs or classes?
For example I want to program a "Game of Live". There could be a class creature with property like amount of neighbours and methods like die or stay.
If i have a gamepad with just 10x10 fields, i have to deal with 100 objects?
Or schould I build a class gamepad?
Daniel
|
|
|
|
|
For me personally, if I have a lot of entities ( for example, cells on a grid ), it makes a LOT of sense to group all the properties of one cell into a struct and have an array of them. I don't see any really viable alternative to this, and it works well. You can iterate over the objects, however many there are, and write the code to deal with one object, once.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to build a match generator for a scoring program for some friends of mine... part of the task is to randomly generate match pairing with a few rules... teams shouldn't play back to back rounds, if more then 1 field is running teams shouldn't be scheduled to play one both fields at the same time, etc.... I've worked this out for the most part, but I'm running into a few issues and I wanted to throw this out to see if there are other ways to do this... So here's a quick walk through of how my code works right now, and I'll try to comment things accordingly so things line up:
1. Get all the teams playing in the event
2. Load team id's into an array
3. Go through the team array and load every possible match into the raw matches array
4. Randomly draw a match from raw match array
5. Check both teams to see if they have played in the last 2 rounds
6. If not, write to database as next match
7. Repeat process to until raw matches are done.
8. If it's set that teams will play each other multiple times, repeat entire process.
Part of what I need to do is come up with a way to determine my recently played buffer... right now it's set to the last 2 rounds, so it holds 4 teams. If only 5 teams are in the event, it's pretty much useless, so I've had to add checking to limit how many times it tries to pull a match that isn't putting a team back to back...
Thanks for any input!
and here's my code....
public void buildRounds(int fields, int times, int eventId)
{
OleDbConnection oConn;
OleDbCommand oComm;
OleDbDataAdapter adapter;
DataSet data = new DataSet();
string sSql;
int totalTeams;
int foo;
int currentField = 1;
int currentRound = 1;
Random random = new Random();
oConn = new OleDbConnection(connectionString);
try
{
oConn.Open();
for(int rounds=1;rounds<=times;rounds++)
{
sSql = "SELECT count(*) from eventDtl where eventID = " + eventId;
oComm = new OleDbCommand(sSql, oConn);
totalTeams = Convert.ToInt32(oComm.ExecuteScalar());
sSql = "SELECT teamID from eventDtl where eventID = " + eventId;
oComm = new OleDbCommand(sSql, oConn);
adapter = new OleDbDataAdapter(oComm);
data = new DataSet();
adapter.Fill(data);
ArrayList array = new ArrayList();
ArrayList teamBuffer = new ArrayList();
ArrayList rawMatches = new ArrayList();
foreach(DataTable myTable in data.Tables)
{
foreach(DataRow myRow in myTable.Rows)
{
array.Add(myRow["teamID"]);
}
}
foo = array.Count;
for(int i = 0;i<foo;i++)
{
for(int j=i+1;j<foo;j++)
{
rawMatches.Add(array[i] + " " + array[j]);
}
}
foo = rawMatches.Count;
while(foo>0)
{
if(teamBuffer.Count > 4)
{
teamBuffer.RemoveAt(0);
teamBuffer.RemoveAt(0);}
int myIndex = 0;
int team1;
int team2;
int match;
int counter = 1;
do
{
match = random.Next(0,foo);
if(currentField>fields)
{
currentField=1;
currentRound++;
}
string [] teams = rawMatches[match].ToString().Split(' ');
team1 = Convert.ToInt32(teams[0]);
team2 = Convert.ToInt32(teams[1]);
if(counter > foo){
myIndex = 0;
break;}
if(foo>4)
{
foreach(Object bar in teamBuffer)
{
if(Convert.ToInt32(bar) == team1 || Convert.ToInt32(bar) == team2)
{
myIndex=1;
break;}
else
myIndex=0;
}
}
counter++;
}while(myIndex==1);
teamBuffer.Add(team1);
teamBuffer.Add(team2);
sSql = "insert into rounds (eventID, roundNum, field, team1ID, team2ID) values ("
+ eventId + ", " + currentRound + ", " + currentField + ", " + team1 + ", " + team2 + ")";
oComm= new OleDbCommand(sSql, oConn);
oComm.ExecuteNonQuery();
currentField++;
rawMatches.RemoveAt(match);
foo = rawMatches.Count;
}
}
oConn.Close();
}
catch(Exception ex)
{
oConn.Close();
throw new Exception("Database error. " + ex.Message);
}
}
}
|
|
|
|
|
Break it into classes and mark thier actions. Its easier to read.
Check out UML "use cases" that might show you some valuable insight.
Use an IList or IEnumerable interface to track groups of teams
Could use a Queue collection to assign teams
Check CollectionBase class for details on the ILIst
Good job for your first try though
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hi,
consider following statements:
class KeywordToken : DefaultTokenImpl, IVisitableToken
{
public KeywordToken(string name)
: base(name)
{
}
void IVisitable.Accept(ITokenVisitor visitor)
{
visitor.VisitKeyword(ToString());
}
}
what does "visitor.VisitKeyword(ToString());" mean?
Is "visitor" an instance of "ITokenVisitor" interface or something else?
How it can invoke "VisitKeyword" by itself?
this is an example of microsoft visual c# .net step by step.
thnx.
|
|
|
|
|
adafaaa wrote: what does "visitor.VisitKeyword(ToString());" mean?
It means that the VisitKeyword method on visitor is invoked with a string parameter, the value of that parameter will be the return value of this.ToString() . (The use of this in this case is implicit)
adafaaa wrote: Is "visitor" an instance of "ITokenVisitor" interface or something else?
You cannot have an instance to an interface as it is not a concrete type. visitor will be what ever type it was created as. That type will derive from ITokenVisitor at some point.
adafaaa wrote: How it can invoke "VisitKeyword" by itself?
I don't understand this question.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
adafaaa wrote: what does "visitor.VisitKeyword(ToString());" mean?
Is "visitor" an instance of "ITokenVisitor" interface or something else?
VisitKeyword is a method defined in the ITokenVisitor interface (or one of the interfaces implemented by ITokenVisitor ). visitor is an instance of a class that implements ITokenVisitor . The actual instance type is irrelavent; the only thing that matters is that it implements ITokenVisitor .
I'm not sure what you mean by invoking VisitKeyword by itself. It is a member of the ITokenVisitor interface and you're calling it on an object that implements that interface.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hi,
Is an Interface a Reference Type?
can an Interface refer to an object?(we know that this object inherited from the Interface).
consider following statements:
private IVisitableToken[] tokens =
{
new KeywordToken("using"),
.
.
.
}
now is tokens[0] an instance of IVisitableToken or something else?(we know that an Interface cannot have any instances).
thnx.
|
|
|
|
|
adafaaa wrote: Is an Interface a Reference Type?
An interface is just a set of method and property descriptions that an object that inherits from it must implement. If you have a variable declared as an interface, the object it references will be a concrete type that is derived from the interface.
adafaaa wrote: can an Interface refer to an object
interfaces cannot have fields, therefore they cannot refer to an object.
adafaaa wrote: now is tokens[0] an instance of IVisitableToken or something else
You cannot have an instance of an interface as it is not a concrete type. You can only have instances of concrete types (interfaces and abstract classes are not concrete types)
tokens[0] is a KeywordToken (in this instace, because that is what you stored there). You can, of course, store an instance of any other object that inherits from IVisitableToken also.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Here's the question: textboxes themseleves already handle all these events so if I want to make a menu item that is going to do the same thing how do I get it to simply use the functionality that's already built into the textbox? If I put a menu on my form and add and edit menu that has Cut, Copy, Paste, etc and the default shortcut keys Ctrl X, Ctrl C, etc then the textboxes no longer have that functionality.
So the question is how do I get my menu commands to simply use the textboxes already built-in functionality?
Thanks for the help.
- Aaron
|
|
|
|
|
monrobot13 wrote: If I put a menu on my form and add and edit menu that has Cut, Copy, Paste, etc and the default shortcut keys Ctrl X, Ctrl C, etc then the textboxes no longer have that functionality
My guess would be that you are overriding the default textbox menu with your own, so in essence this is why you're disabling the default behavior. So if this is the case, I guess you would have to re-implement this kind of behaviour in your new menu. I don't know whether you can merge the default functionality with your own. But then again, why on earth would you want to do that?? Correct me if I am wrong, but it's like re-inventing the wheel... isn't it?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
In C#, is it possible to pass a parameter to a function receiving pointers. A simple example
int somefunc(int* i)
{
return *i;
}
Is it possible to call a function like this in C#?
|
|
|
|
|
No, but you can use the ref or out keywords to achieve similar results.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Or are you talking about calling a native function? In which case you can set up an unsafe block of code and use pointers there. However, you have to change the options in your assembly as unsafe blocks not supported by default.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Thank you guys!
It is a DLL created from VC++.Net with this native type int, I thought int in VC.Net is just an alias of System.Int32. Since I want to pass the results back from DLL to the C#. C# see it only as a pointer.
The VC++.Net functions are like
int Somefunction(int& i)//Passing by reference
{
int iother = OtherFunction(&i);
}
int OtherFunction(int* j)//passing by pointer
{
*j=5;
return 0;
}
To receive the change in i, how actually I can use either ref or unsafe block?
C# is really new to me, would you please give me some sample code to call function Somefunction to get the result in i?
Thanks a lot!
Devin
|
|
|
|