|
The main code decides on the word size of the process (either directly by being built for 32 or 64bit, or by looking at the OS when managed and "AnyCPU"); everything else must comply to the top-level code.
Hence, if resource.dll is 32-bit, it all must be 32-bit; there is no way around that.
if parent is managed and built for "AnyCPU", there are hacks to modify it and effectively become built for "x86" (the difference is a single bit in the exe's header!); you need "corflag" or similar, see e.g. http://stackoverflow.com/questions/1507268/force-x86-clr-on-any-cpu-net-assembly[^]
|
|
|
|
|
Thank you.
I will work with that tomorrow and try and get it working.
|
|
|
|
|
Hi Luc,
I ran corflags against my resource.dll and I got the following message
"corflags : error CF008 : The specified file does not have a valid managed header"
I know it was compiled in Delphi, but having no experience with Delphi and having not encountered this type of conflict before, I'm pretty confused on how to proceed?
|
|
|
|
|
no surprise here. Now re-read what I wrote earlier.
|
|
|
|
|
Ok, I see where you were going with it now.
Here are the results from the parent exe file
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
I forced it to 32bit and tried to start it, 8 other dependencies are failing, probably because they have the 32bit flag set to 0 so I shall scrap this idea unless there is a way to do something similiar on the unmanaged resource.dll .
Thank you for your help.
|
|
|
|
|
No, there is not. Unmanaged means native code, and that is entirely different for 32/64 bits.
|
|
|
|
|
hi..
am new to c#..
am getting an error below code..wch is wrking fine with Vb..
int legseq = 0;
if (legseq == " ")
{
legseq = 0;
}
Error: Operator '==' cannot be applied to operands of type 'string' and 'int'
I dont want to use 'null'instaed off " ". and dont want to make int as nullable. can anybdy help?
Regrds,
Reta
|
|
|
|
|
In C#, as in many other languages, " " is a string holding a single space.
You can't store text in an integer, all it can hold is a number in a particular range (and 0 is always a good number).
bigphish wrote: I dont want to use 'null'instaed off " ". and dont want to make int as nullable. can anybdy help?
Maybe you should start by telling what you do want. Or just make it happen.
|
|
|
|
|
Thnks for the reply Luc.
will the below code can give the same result?
int? legseq = 0;
if (legseq == null)
{
legseq = 0;
}
|
|
|
|
|
that would compile, however it too does not make sense to me. the variable starts by holding zero, so why compare it to " " in the original code (something it can't hold), or to null here (something it could but won't hold).
start by telling what you do want (in functional terms, not in bad code), before you attempt to code it.
BTW: the best way (quality wise and speed wise) to learn a new programming language (or programming in general), is by choosing, buying, and studying a book on the subject. And I do mean a real book, not an e-book or a web course.
|
|
|
|
|
You have introduced a redundant piece of code there. If you leave the type is int rather than nullable int, unless you explicitly assign it a value, it will already be zero. The default value for int is 0.
|
|
|
|
|
Using null wouldn't turn it into meaningful code either, but at least it would compile. With the warning "The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'"
|
|
|
|
|
|
Yes, I'm sure. You changed the type of test as well as its initialization. Of course it's going to be different.
|
|
|
|
|
|
I guess I could have been clearer..
And I'm still wondering what he actually wants to do.
|
|
|
|
|
He absolutely positively undeniably wants to make sure legseq is zero, I'd say.
|
|
|
|
|
harold aptroot wrote: And I'm still wondering what he actually wants to do. He is creating a security firewall to prevent external hacking that would make his int a string ?
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
What you are doing here is comparing a string " " to an integer.
This is not acceptable in C#.
You can compare legseq to 0 or convert legseq to string.
The default value of an int is 0 so if you dont assign anything to legseq, its value will be 0.
|
|
|
|
|
bigphish wrote: wch is wrking fine with Vb..
Which shows VB is absolute rubbish. You cannot compare apples with oranges.
You need to convert one of the two to the other type. (depending on what you want).
you could check out int.TryParse or the ToString method or the Convert classes. Each has it's own advantages.
oh and please. Loose the text speech and check your post for spelling before submitting. It's nicer for us the read
V.
|
|
|
|
|
Okie.. sorry if my code was unclear..
I am converting some code from vb to c#, wch will take some values from Oracle database and will insert in to a MS access database..so I cant view the oracle database wch is in some other server.legseq field in oracle database is taking data dynamically , which can be empty also some times.
so while inserting in to Access database I need to check if the value of legseq is empty.if it is empty i need to make it Zero before inserting.
hope its clear now..
|
|
|
|
|
You should almost certainly do this with DataAdapters and other useful things in System.Data instead of trying to convert the VB code verbatim. Handling of database nulls is something which I suspect will not work the same in the two environments anyway.
|
|
|
|
|
Better
My guess is that you need to check before you have the 'int leqseq' value.
Here are some things to look at:
- Can the value leqseq be null ? if so a nullable int (int?) or checking agains DBNull.Value is the best way to go.
then you can do this:
for int?
if(leqseq.HasValue){
}
else{
}
for checking against DBull.Value
- do you have a datatable, dataset, resultset somewhere?
in that case you can compare the database value against DBNull.Value .
if(mytable.Rows[rowindex]["columnname"] != DBNull.Value){
}
else{
}
If the value leqseq cannot be null in the database
you need to test if has an invalid 'value' like 0 or -1 or something, but this is bad database design. In that case you don't need a string either, but just compare against the 'fake' value.
Hope this helps.
V.
|
|
|
|
|
I don't know how you are retrieving the values from the Oracle database, but ADO.Net DataReaders have an IsDBNull property, which can be used to check if a result is null, so you can do something like this :-
count = dr.IsDBNull(0) ? 0 : (int)dr[0];
and that will give you a 0 if the result is null, otherwise will return the value (assumes your data reader is dr ).
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
yes .Thanks alot for the help
|
|
|
|