|
Thhanks Heath...Ok,I'll do it. But that error does not happend at regular time,it only happend if I change the some charachters inside my application.
Mazy
No sig. available now.
|
|
|
|
|
If you're changing the cipher text it shouldn't decrypt. What's the point of encryption, then? Throwing an exception is what should be happening in some cases, and "Bad data" sounds about right. I got that once or twice when testing my XML Digital Signatures sample code to make sure that changing the signature digest invalidated the signature.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Fair enough.
Mazy
No sig. available now.
|
|
|
|
|
I am looking for a way to enter and edit text on an image displayed on a form. Any suggestions
|
|
|
|
|
|
I have a control 'MyControl' with a property of type 'MyObject'. MyObject has a property 'MyField' that is a enum type. I want the type of enum to vary depending on a another property of MyObject called 'MyFieldType'. E.g. if MyFieldType = TypeA, MyField returns EnumA. See code below:
public enum FieldTypes
{
TypeA,
TypeB
}
public enum EnumA
{
Big,
Medium,
Small
}
public enum EnumB
{
Short,
Tall,
Squat,
Huge
}
[DefaultProperty("MyFieldType")]
public class MyObject
{
private FieldTypes m_MyFieldType;
private object m_MyField = 0;
public FieldTypes MyFieldType
{
get {return m_MyFieldType;}
set {m_MyFieldType = value;}
}
public object MyField
{
get
{
if (MyFieldType == FieldTypes.TypeA)
{
return (EnumA)m_MyField;
}
else
{
return (EnumB)m_MyField;
}
}
set
{
m_MyField = value;
}
}
}
My problem is that the MyField property is not editable via a dropdown list in the designer. It appears as a greyed-out (read only) string representation of the respective enum (EnumA or EnumB). I've tried writing a TypeConverter (inheriting from EnumConverter) but just ended up going round in circles.
Does anyone have an example of what I'm trying to do or point me in the right direction?
Thanks
|
|
|
|
|
It is because you are returning object. That said, if you return an object from an encapsulting class, and apply the ExpandableObjectConverter, you should be able to access the "real" properties.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
MyObject is already using the ExpandableObjectConverter that's not the problem. It's the MyField property. If I use an ExpandableObjectConverter for this property, the property becomes editable, but as a string not an enum. I think I need to use some kind of EnumConverter and dynamically specify the enum type, but I don't know how.
|
|
|
|
|
You wanna make a typeconvertor for the type and apply that. The key methods to override (implement) is SupportValues() and GetSupportedValuesCollection() (the method names are most likely wrong too lazy to look them up). This will automaticaly create an "enum" like convertor, do not implemeted any other methods.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
What is the best way to update a treeview node in place?
I have a tree view that exposes the nodes to an XML editor. When the value of this node changes [in the XML editor], I' like to update the tree to show the new value.
Coding in the heartland
|
|
|
|
|
There is no direct binding support such as this (though you could add support). Instead, watch the XML fragment/file for changes and update the node text. There are so many ways of doing this, however, that it'd be difficult to list them all here.
You could, for example, watch for any changes in your editor (like for a multi-line TextBox handle the TextChanged event). When it changes, rebuild your tree from the XML information in the TextBox . To update just the node who's representation has changed in the XML fragment/file, it would be much more difficult. You could construct a path by recursing up the parent elements and pre-pending the text each time, using the TreeView.PathSeparator to separate each node. Then use that to find the node in the tree and update only that TreeNode . This would get increasingly difficult for added and removed nodes because you would also have to take state into account. Most implementations I've seen simply refresh the tree, which is apparent for larger XML hierarchies.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath.
Fortunately, for this application I won't have to worry about too many added or removed nodes.
I continued to play around with the functionality I was looking for. The combination of events that gives me the functionality I'm looking for is both KeyUp and Leave. But, I see that TextChanged would work just as well. Thanks.
I set a flag to manage the dirty state of my text box and this seems to work well even when I have a 6mb XML file loaded in the tree.
I was looking for the method that I use to update just a single node in place. As you said, "simply... refresh the tree". Thanks. That works fine.
Coding in the Heartland
|
|
|
|
|
Hopefully one of you guys could help me with this query about enumerations.
Heres a simple enumeration :
public enum e {Val1=1, Val2=2 }
This allocates Val1 as int 1, Val2 as int 2 and so on, so if i do :
int x = (int) e.Val2;
x is given the value of 2
Now heres the thing, I want to allocate four int values, now I know this code isnt right but it gives an idea of the effect I am after :
public enum e {Val1="1,2,3,4", Val2="5,6,7,8"};
So if I use the following code :
int[] x = (int[])e.Val2
Which would populate the int array X with the values 5,6,7,8
|
|
|
|
|
Anonymous wrote:
public enum e {Val1="1,2,3,4", Val2="5,6,7,8"};
The reason this does not work is because enum is intrinsically an int .
Anonymous wrote:
int[] x = (int[])e.Val2
Even if e.Val2 returned a string this code would not work because it is not possible to directly convert a string to an array of int s.
An idea might be to set up an array of arrays that map to the enum:
public enum e{Val1 = 0, Val2=1}
int[] x = (int[])myArray[(int)e];
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
That is absolutely not supported! No arrays, no strings, ... you'd get the following error:
Type byte, sbyte, short, ushort, int, uint, long, or ulong expected
Hmm however you can combine 2 int16s into an int32 and find the values by doing some bit manipulation (in a function you call to calculate the values based on the int32 of the enum) I think, but that is way too complicated...
Why would you want to do such thing anyway?
greetz
*Niels Penneman*
Software/Dev Site Personal Site
|
|
|
|
|
As the two previous posts said, this isn't possible for the reasons they gave. You can, however, use read-only members in a class like so:
public sealed class Values
{
private Values() {}
static Values()
{
Val1 = new int[] {1, 2, 3, 4};
Val2 = new int[] {5, 6, 7, 8};
}
public static int[] Val1;
public static int[] Val2;
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I use remoting in my application, which proofed to be very useful but now i have a small problem.
In the server application the remote object is register as an available service in singleton mode.
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RemoteObject),
"Server",
WellKnownObjectMode.Singleton );
Now I'm searching a way to unregister it in the server application, so no remote calls from clients are processed?
|
|
|
|
|
If you use a configuration file to publish the types you want remoted, you can use the RemotingServices.Disconnect to stop the object from receiving further messages. See the documentation for that method for more information.
The only other way is to stop the AppDomain in which the WKO is registered. If you're using a Windows Service, you can stop the service both manually using the Services snap-in or the ServiceController class. If you're hosting this in another process, you could create a separate AppDomain and launch an executable that registers the WKO, then when you want to stop it unload the AppDomain using AppDomain.Unload .
One more way that wouldn't unregister the WKO but would keep it from processing requests (which I wouldn't recommend because clients will still see the published WKO) would be to put the interface in a shared library and the implementation of that on the server. Have an internal method that you can call that could do something like set a flag. In each of your interface implementation methods / properties, check that flag and either don't return anything or throw some sort of exception, like NotSupportedException or something. The first two methods are more complete, IMO.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for info!
I'm now using this code in my server application and it functions very well.
this.remoteObject = new RemoteObject();
System.Runtime.Remoting.RemotingServices.Marshal(this.remoteObject, "Server");
System.Runtime.Remoting.RemotingServices.Disconnect(this.remoteObject);
|
|
|
|
|
I have just finished creating a C# class library that has public classes available in it, when i include this lib in my test applications it works fine, but when i passed it to the division i wrote it for they complained it will not work. The error they get is as follows:
"An unhandled exception of type 'System.TypeLoadException" occurred in unknown module. Additional information: could not load type"
It then lists the class they are trying to access from my component.
They are adding a reference to an existing C# app, when they create a test app and add it the component works fine.
My question is what does this unhelpful error message mean and how can i fix it?
Any help would be great
Simon Wren
simon.wren@nesltd.co.uk
Senior Software Architect
National Energy Services Ltd
Visit Us: www.nesltd.co.uk Or: www.nher.co.uk
|
|
|
|
|
A TypeLoadException can occur for many reasons. Since each Type is a fully-qualified class name (includes an optional namespace) in an assembly that has a version, culture, and public key token, any change to that assembly would cause an invalid type. For instance, if you compiled your app against version 1.0.0.0 of your library and the library version was 1.0.0.1 and you had no binding redirection configured in your .config file, a TypeLoadException will be thrown.
If the assembly in which the Type is contained is not in the current directory, a path configured in the <probing> configuration section of your .config file, or the Global Assembly Cache (GAC) a TypeLoadException will be thrown.
How can you avoid these problems? For one, stop using automatic versioning (when the AssemblyVersionAttribute contains an asterisk). This was, IMO, a bad addition to .NET because versions are VERY important in resolving assemblies, unlike native DLLs. Automatic versioning for them would've been nice (it was possible through macros) but for .NET assemblies it is bad. You have no control over the assembly versions.
Second, use project references. If you have the source to a project and want to reference the resulting assembly in another project, click on the Projects tab of the Add References dialog and add a reference to the project to be configured as a dependency. This keeps track of the outputs and will compile the same build configuration of each project (Debug, Release, etc.). This also makes sure that any changes in the dependent assembly will cause the that to be recompiled when you compile the assembly that has a that dependency. If you use a file reference, this will not happen automatically. If you continue to use automatic versioning, you should definitely use a Project reference so that any changes that cause the version # to be different will recompile the target assembly which will bind against that new version.
Finally, make sure that all dependent assemblies exist on the target machine. The base class library assemblies will already be present if .NET is installed (and obviously it must be). Make sure the correct version of .NET is installed, too. While each framework is both forward- and backward-compatible, they are not 100% compatible between versions. Things change some times so some Types may be different. Also make sure that any third-party libraries that your libraries reference are also installed into the GAC (so you don't have to worry about resolving assemblies).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Great thanks, i think it must be the automatic versioning as we are using references already.
It makes sense now as the new test apps we created that did work did not have a previous reference to the component, while the app that didnt work had used a beta version of the
component.
Thanks again for your help
Simon Wren
simon.wren@nesltd.co.uk
Senior Software Architect
National Energy Services Ltd
Visit Us: www.nesltd.co.uk Or: www.nher.co.uk
|
|
|
|
|
I have a panel consisting of buttons.
How can I select (set focus) on severel buttons?
Let's say that the panel consists of 8 buttons, first I want to groop the buttons in to two groops(4 * 2), a timer shall then switch between the two groops and by clicking the mouse, the sellected groop then gets grooped in another groop (2 * 2) and the timer switches (sets focus) between the new groop, and so on, until there is only one button left. (In Norway we call this scanning)
Is there an example of somthing like this on the web?
Since my buttons consist of pictures, I need to somehow view the buttons that are set focus on, any idees?
Thanks
Thomas
Sorry about my bad english
|
|
|
|
|
Focus can only be given to one active control. This is universal. By given a control focus, you give it the input focus. You can't input into two controls at once (though you can give the appearance by echoing). All modern OSes are like that.
Now, if you want the groups of buttons to be selected, that's different. Just like in Windows Explorer (or in any other window manager) you an select multiple items, but only one item has the focus. You could extend the Button class and give it a Selected property (a Boolean most likely). In the set accessor, you could flag the control and invalidate it so that next time OnPaint is called you can draw the picture differently to signify that it has been selected (perhaps drawing a rectanglular border using the Bounds rectangle).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Does anybody know how it would be possible to get the current mouse coordinates within a PictureBox control?
If that doesnt make sense, read on. I am playing around with creating a chess game, the board is an image that is placed within a PictureBox. To be able to process piece selections etc I need to be able to retrieve the part of the image this user has clicked on.
At the moment I am using a rather inelegant solution, by using this.location & cursor.location to calculate where the image was clicked.
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|