|
Luc,
Most helpful, I do have a book on C# and had come across the ref keyword.
However I was only using it in the member function declaration and not when I invoked it. I think it did not help that i've jumped in at the deep end with my first app - could have chosen something a bit easier, I am learning quite quickly though!
Cheers all Rich.
|
|
|
|
|
You're welcome.
I still recommend you work your way through the book you have, possibly
skipping those specialized chapters that don't interest you yet.
You really must grasp all the implications of value and reference types
before you can do any serious work.
|
|
|
|
|
Well, I thought I did, but obviously not. I've been trying to do run through the book and code the app at the same time. Guess ill hit the book a bit more...
|
|
|
|
|
Try this one,
http://www.csharphelp.com/archives/archive77.html
|
|
|
|
|
Dear Friends,
I have to validate digital signature inside an XML which we receive from our client. Client has given us their cetificate also which contains their public key. I am using following lines of code to verify the signature but I am getting false everytime. Moreover, .Net framework does not tell what went wrong behind giving this false output value. I am using .Net framework 1.1/C#.
<br />
XmlDocument xmlDoc = new XmlDocument();<br />
xmlDoc.PreserveWhitespace = true;<br />
xmlDoc.LoadXml(SamlXML);<br />
bool validSaml = false;<br />
<br />
X509Certificate cert = X509Certificate.CreateFromCertFile(certificateFileName); <br />
XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);<br />
mgr.AddNamespace("saml",this.samlAssertionNameSpaceURI);<br />
mgr.AddNamespace("ds",this.digitalSignatureNameSpaceURI);<br />
XmlNode nodeSignature = rootNode.SelectSingleNode("//saml:Assertion//ds:Signature",mgr);<br />
if(nodeSignature == null)<br />
{<br />
this.errorNumber = Const.SAML_ASSERTION_SIGNATURE_INVALID_NOT_DEFINED;<br />
this.errorMessage = "ds:Signature node is missing";<br />
return validSaml;<br />
} <br />
<br />
SignedXml verifier = new SignedXml(xmlDoc);<br />
verifier.LoadXml((XmlElement)nodeSignature);<br />
<br />
KeyInfo key = new KeyInfo();<br />
key.AddClause(new KeyInfoX509Data(cert));<br />
verifier.KeyInfo = key;<br />
<br />
if(verifier.CheckSignature())<br />
validSaml = true;<br />
else<br />
validSaml = false;<br />
I am getting false everytime when I call CheckSignature() method. Can someone please help me. I would appreciate any type of help in this matter.
Thanks and Regards,
Amit
|
|
|
|
|
Hi
I'm trying to serialize a class. Everything works fine, but I have problems serializing a property which returns one of my custom types. This is the class:
public MultiSampleType MultiSampleType
{
get { return multisampleType; }
set { multisampleType = value; }
}
public bool VSync
{
get { return vsync; }
set { vsync = value; }
}
public Resolution CurrentResolution
{
get { return resolutions[currentResolution]; }
}
Both MultiSampleType and VSync get serialized, but CurrentResolution does not. I have marked my own class Resolution as [Serializable], but it doesn't work. This class also contains some public properties.
Any suggestions?
thanks in advance
/edit:
Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this. Is there a way to achieve this without it?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this
But that doesn't make any sence I guess, you will not be able to DeSerialize it without an setter.
All the best,
Martin
|
|
|
|
|
Yeah, makes sense
I just noticed another weird thing though. Deserialization worked fine most of the time, but sometimes I get this:
XmlSerializer serializer = new XmlSerializer(typeof(T));<br />
ret = (T)serializer.Deserialize(stream);
Exception: IvalidOperationException (malformed XML file)
No wonder, the file looks like this at the end:
...
</CurrentResolution>
</ResolutionManager>anager>>
What the hell is wrong with the tag here? Is the serializier messing up something?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Any property that will be serialized/deserialized has to be read/write. So a public field, or a property with both public get and set. It can't serialize if it doesn't have a public get and it can't deserialize if it doesn't allow set.
My article[^] might help.
|
|
|
|
|
Hi,
When you create a Form with the Designer, VS2005 (maybe earlier?) adds code to override the Dipose(bool) method as follows:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Every time I step through this function in the debugger, components always == null. Am I supposed to be allocating components and adding items to it manually, so that they will be disposed?
|
|
|
|
|
I'm moving from VB to c#, I'm getting there, but one thing has be baffled.
How do i define the length of a string?
for example, if i wanted a string exactly 20 bytes long?
Thanks
|
|
|
|
|
You don't define the length of the string. You just set the string to what you want it to be, e.g.
string myString = "hello world!";
If you need to have a string of a certain length, use a char[] instead, e.g.
char[] theCharacters = { 'h', 'e', 'l', 'l', 'o' };
or alternately
char[] theCharacters = new char[20];
|
|
|
|
|
Thanks for the speedy reply, it was helpful
Looks like my program needs a rewrite ^^
|
|
|
|
|
Although characters aren't necessarily bytes anyway.
|
|
|
|
|
hi all,
i deeply hope that you guys have an answer to my question which is the following:
i've got a menu which controls a couple of user controls representing the pages of my app. only the currently selected page is visible. my problem is that when I resize my app and then switch to another (formerly hidden) page and change its visibility to visible it first paints int its old size and afterwards resizes itself to match the new parent proportions. So basically it is painting twice which is pretty ugly.
Does anyone know how to handle this problem? I'm pretty much stuck
I'd appreciate any help,
thx, Bjoern
|
|
|
|
|
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
|
|
|
|
|
Many different ways you can go abouts doing this. SQL Substring Function[^] may help guide your way
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i think you're looking to use the "LIKE" clause of SQL.
In your SQL statement you'll be doing something like this:
<br />
string myStr = "world";<br />
<br />
string sSQL = "SELECT field from table where field LIKE @mystr;";<br />
<br />
dbcommand.parameters.addwithvalue("@mystr",myStr);<br />
<br />
string mydbvalue = dbcommand.executescalar();<br />
|
|
|
|
|
What would "LIKE" return in this condition:
String to be found:"????2805"
and string that is checked is "2805-2705"
it will still find the sub-string but this is not what we were looking for.... wont it...
|
|
|
|
|
Hello,
I have a DataGrid (not DataGridView) control .NET 2.0 bound to a given DataTable. One of the columns contains alphanumeric values which do not get sorted well: e.g. take the IDs A-12, A-103, B-3, ... Z-0. The default sorter of the DataGrid sorts the first two items incorrectly (A-103, A-12).
If I used a custom IComparer implementation I would call string.CompareOrdinal in order to obtain the actual compare result but apparently data-bound grids cannot be sorted that way.
I would definitely appreciate any suggestions to resolve this issue. I think this can be achived by creating a derived Control or by handling the SortCompare event of the DataGridView control.
Thanks,
Stanimir
|
|
|
|
|
Hi,
when I try to evaluate a member in debug mode by pointing on a variable to see its content, the data that is displayed is i hexadecimal. For example, I do the following instruction:
int t=-1;
After passing the instruction, I try to see the content of the variable 't' and what I see is '0xffffffff '.
All the data I try to evaluate appear using the same notation.
Do you know how I can change that to see them in decimal ?
Thanks a lot for attention.
Patrick.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Right click on the variable display and the popup menu has an option for hexadecimal. Just uncheck it.
|
|
|
|
|
Thanks for answering. But, there is no option for hexadecimal, so I can't uncheck it.
I'm working with Visual Studio 2005.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
It's there. It's called Hexidecimal Display.
|
|
|
|
|
Ok, I found it. But it's not directly available in the popmenu displayed after pointing a variable. I did it from the 'Watch' window.
Thanks !
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|