|
You are misunderstanding what WOW64 means.
WOW64 (windows on windows 64) is a windows 32bit emulator that runs on windows 64 bit. The wow64 folders/regs keys are for data from 32bit programs that are running on windows 64 (via the emulator).
You obviously are writing a 32bit program. Hence, it is running on WOW64. Which means when you write to the registry it goes in the WOW64 location. This is the correct behaviour. On windows 64, the registry is 64bit, and cannot be accessed by 32 bit programs. WOW64 allows a special area of the registry to be accessed by 32 bit programs.
(By the way, by default c# compiles in "architecture agnostic mode" which means it is both a native 32 and 64 bit program at the same time. If you are using C# you have obviously changed the settings to be for a 32bit cpu only. Consider changing it back. Right click on the project, go to properties, and look at the build tab. There is an option called "platform target" this should be set to "any cpu". If you do this, on a win64 system, the app will run as a native 64 bit app, so won't be using wow64 any more. I suspect you have it set to x86 which means 32bit cpus)
Simon
|
|
|
|
|
Thanks Simon I will do that.
-Hemal
Hemal Kotak
|
|
|
|
|
My app needs to take a pdf file and compress it into an .arc file (for a third party bit of software to pick up, so i have no choice in the compression format).
I have googled it but am struggling to find any c# solutions or opensource api's.
Any links, ideas etc most welcome
Mark
|
|
|
|
|
|
Good day. I'm writing an application where I specify types in a config file and these types then need to be instantiated through reflection.
How can I create a System.String object through reflection? And a System.Int32 object with a value other than 0?
I've got the following code:
Type paramType = Type.GetType("System.String");
object obj = Activator.CreateInstance(paramType);
but when I try to do this for a System.String, it tells me that such a constructor doesn't exist (one with no parameters). When I run the code for a System.Int32 object, then the object is created, but I cannot pass the constructor a default value such as Activator.CreateInstance(typeof(int), 3, 5);
How can I create a type such as System.String, System.Int32 or such a type and assign a value when it's created, using reflection?
|
|
|
|
|
Hi,
i'm not sure why you are using the Activator-object. The string has no constructor without parameters (check http://msdn.microsoft.com/en-us/library/system.string.string.aspx[^]), so you have to pass something to get a string object. What you could try is to use the ConstructorInfo of the Type.
<br />
ConstructorInfo oInfo = paramType.GetConstructor(new Type[] { typeof(char*) });<br />
object oString = oInfo.Invoke(new object[] { "This is a test."} );<br />
Hope this helps you a bit.
Regards
Sebastian
|
|
|
|
|
The values in my app.config file actually looks like this.
<parameter type="System.String" value="32">
<parameter type="System.Int32" value="32">
Now, I can't call
int i = new int("32") or,
string myString = new string("32"),
since no such constructors exist. I need to somehow create objects of these types and assign these values to them. But I'm looking at a generic way of doing this.
(I don't want to write code like
object obj = null;
if(paramType is Int32)
obj = 32;
else if(paramType is String)
obj = "32";
I want to avoid code like this.
Any ideas?
|
|
|
|
|
Take a look at the TypeConverter class.
object obj = TypeDescriptor.GetConverter(paramType).ConvertFromInvariantString("32");
|
|
|
|
|
This one's the answer I was looking for. Thanks a lot for the help.
|
|
|
|
|
Didn't know that values from the app.config are strongly typed. There are all coming as string, or?
|
|
|
|
|
No, they're not strongly typed, otherwise it would have been much easier. They all come as a string.
|
|
|
|
|
Ok. So i'm stuck here. How does you know if the app.config entry is an integer? Let me say it this way, somewhere in your app you have to consume the app.config entry in a typed way. Exactly at this point you know what you were expecting from the config file. What if you put an entry to the app.config with value 32, parsing the whole as int, but you are expecting a string in your app?
What do you want to achieve exactly?
Regards
Sebastian
|
|
|
|
|
I want to have the following entry in my app.config file:
...
...
1: <Parameter type="System.Int32" value="32" />
2: <Parameter type="System.String value="Hallo" />
Ok. Now the "value" attribute of the "Parameter" tag will always be a string value when retrieved from the app.config.(that's how the Custom Configuration files were written). Now by looking at the "type" attribute, I want to cast/convert the value of the "value"-attribute to the type specified by the "type" attribute. Something like the following:
So for line 1: the following values will exist.
param.type = "System.Int32"; (String value);
param.value = "32"; (Also a string value as retrieved from app.config.
For line 2: it will be:
param.type = "System.String";
param.value = "Hallo"
Now what I'd like to do is something that would be similar to the following code:
param.type myVariableType = (param.type)param.value;
Where I have a type and cast the value I recieved from the app.config to that type.
(Look in one of the previous threads by Daniel Gruwald. I got an answer for this problem. It was to use the following code.
TypeDescriptor.GetConverter(Type.GetType(param.type)).ConvertFromInvariantString(param.value);
|
|
|
|
|
Am I missing something, or the example below is really impossible.
The class called FirstImplementation derives from GenericClass , and the generic parameter used, FirstClass derives from Base . So from the outside I should be able to cast FirstImplementation to GenericClass<base></base>
public class Base
{
public int X { get; set; }
}
public class FirstClass : Base
{
public int Y { get; set; }
}
public abstract class GenericClass<T> where T: Base
{
public T Item { get; set;}
}
public class FirstImplementation : GenericClass<FirstClass>
{
public GenericClass<Base> Cast()
{
return (GenericClass<Base> )this;
}
}
modified on Thursday, January 15, 2009 6:18 AM
|
|
|
|
|
That's not how generics work unfortunately. You can't do this
GenericClass<firstclass> var1;
GenericClass<base> var2;
var2 = (GenericClass<base> )var1;
Your var1 & var2 variables are different types. One is a generic class using base as it's type member, and one is using FirstClass as it's type member, you can't cast one to the other, just because FirstClass is a subclass of Base. var1 isn't a subclass of var2. What generics effectively do is define a new class using the type you specified. So it effectively equates to this:
public class GenericClassUsingBase
{
public Base Item
{
get;
set;
}
}
public class GenericClassUsingFirstClass
{
public FirstClass Item
{
get;
set;
}
}
You'll see if you try and cast these you can't do that either:
GenericClassUsingFirstClass var1;
GenericClassUsingBase var2;
var2 = (GenericClassUsingBase)var1;
They are basically different types, just because they are using type parameters that subclass each other doesn't make them subclasses of themselves.
Simon
|
|
|
|
|
Thanks. Great explanation.
I guess I'm not the only one who bumps into this. Any known workarounds? Or rethink the whole implementation from scratch?
|
|
|
|
|
gnjunge wrote: Any known workarounds?
That kind of depends what you are trying to do.
If you are trying to treat generics of a class tree as a tree themselves, I suspect you are slightly misusing the idea of generic classes. You might be better defining explicit classes instead of generic ones, and then having them all inherit from the same interface or abstract class instead if you need that.
What is it you are trying to archive?
Simon
|
|
|
|
|
For now I made my own work around.
The code has changed multiple times, and I'm sure there was a reason for using generics. Have to check it when I have time.
|
|
|
|
|
C# 4.0 brings generic covariance[^]. While the current code will still not compile, inserting an interface will get you going.
public interface IGenericClass<out t=""> where T : Base { public T Item {get; } }
public abstract class GenericClass<t> : IGenericClass<t> {...}
var derived = new FirstImplementation();
IGenericClass<Base> baseInterface = derived;
</t></t></out>
C# 4.0 is still in CTP stage though.
|
|
|
|
|
|
Hi,
I want to add Rows bottom of the Grid but for some reason it goes here and there or always last but one.
MyGrid.Rows.Add();
Thanks
|
|
|
|
|
why do you want to add a row to the DGV?
You only get that output if you add records to your database, refresh, and display the data in DGV.
You have to remember that you dont edit the DGV, you edit your database!
You use the DGV to display data.
You can add and delete rows but not like you ask here, got it?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Anyway at last i got the solution !!
I just built a Data Table that is assigned to Data Grid as a Data Source so whenever i make changes in Data Table things are getting affected.
|
|
|
|
|
Hi all,
I want to call a crystal report from C# application
can i know the syntax and process please
waiting for your reply.
|
|
|
|
|
Hema Bairavan wrote: process please
Go to a bookstore and get a C# and crystal report book.
|
|
|
|