|
Read the EMCA and SDK tool developer docs, then you will know EXACTLY.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
The executable is being created first, which means your code is compiled to MSIL. Then it's run, which means the framework is compiling that again, to something your PC can understand.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to call a com object method which I inherit in c#.net.
The com method signature is :
long GetBaseAssets(
[out] SAFEARRAY(BaseAssetInfo)* psaRecords,
[in, optional, defaultvalue(-1)] long BaseAssetCode);
and the clr create a reference for it as:
public virtual int GetBaseAssets ( out System.Array psaRecords , int BaseAssetCode )
The compiler says that argument 1 cannot convert from 'out taskbarlib.baseassetinfo[]' to 'out.system.array'.
The part in my c# class that calls the method looks like that:
BaseAssetInfo[] BaseAsset;
int intp;
rc = GetBaseAssets(out BaseAsset , intp);
Need your help,
Thanks.
|
|
|
|
|
try object[]
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
thanks for the prompt response.
I did, with not much success.
anyone has an idea ?
|
|
|
|
|
Seeing its an out parameter, try this:
Array input;
Foo(out input);
MyType[] rinput = input as MyType[];
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
I need help trying to open up a mysql database using Visual C#.
|
|
|
|
|
What have you already tried ? Google ? Searching this site ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There's a very nice MySql Connector for .NET on the MySql.org website.
|
|
|
|
|
|
Ado.Net2.0 can enum most of metadata from database
Please pardon my weak English!
|
|
|
|
|
I am unable to see the source code for the first link that you provided. Are there any other suggestions or source code that anyone can provide me with?
|
|
|
|
|
I am trying to add an instantated class (which is an Object - I hope!) to an Arraylist every time the data in the class changes. This instantated object is composed of several other instantated classes (objects).
Example:
ArrayList myObj = new ArrayList();
class foo;
foo.strName = "name";
myObj.Add(foo);
...
foo.strName = "newname";
myObj.Add(foo);
When I look (via QuickWatch) at the Arraylist elements, they all appear to be the same, i.e.,
myObj[0] foo.strName == "newname" &&
myObj[1] foo.strName == "newname".
Yet, I know the data in the class has changed.
Am I doing something that is invalid? What am I doing wrong?
Thanks
|
|
|
|
|
You need to instantate a new object every time. If you just change a member of the object you still have the same object it doesn't automagically create a new object and it'll still be the same object that is already in your ArrayList.
|
|
|
|
|
hi there,
it sounds to me that u are adding only one object to array list.
and actually the reference to the object stored in the arraylist. So whenever u change it's attribute, all objectes in the arraylist will take affect, I think.
So the code should be:
class foo = new cfoo();
foo.strName="name";
obj.Add(foo);
....
foo = new cfoo();
...
obj.Add(foo);
Try it
<< >>
|
|
|
|
|
In your code, you did not instantiate a new foo object, instead you are modifying the foo.strName only.
An ArrayList stores reference to your object, therefore if you store two reference to the same object they will result in the same object.
Try this instead:
ArrayList myObj = new ArrayList();
ClassName foo = new ClassName();
foo.strName = "name";
myObj.Add(foo);
...
foo = new ClassName();
foo.strName = "newname";
myObj.Add(foo);
This will result in two different objects which references are contained in your myObj ArrayList.
Does that help?
Edbert P.
Sydney, Australia
-- modified at 18:58 Wednesday 26th October, 2005
|
|
|
|
|
Thanks to All,
My problem was not quite as simple as I showed in my example (i.e., I have multiple embedded classes involved), but all of you put me on the right track. I didn't realize that a reference to my class was what was put into the Arraylist.
I am able to do what I originally wanted, but had to do it a different way.
Thanks
Don
|
|
|
|
|
After a day of scratching my head, I think I've found the problem with my latest project, however I'm not sure what to do about it.
I've wrapped a legacy DLL with a .NET remoting solution that allows the functions to be accessed easily from ASP.NET. The DLL is used for reporting.
On my test system, with demo configuration and minimal data, everything worked fine.
At the clients site, where the reports are larger, the remoting service returns a null reference exception when the reports are over 4k.
Here is functions P/Invoke signature:
[DllImport("opsrpts.dll", CallingConvention=CallingConvention.Cdecl)]
static extern String DisplayReport(int rvc, int wsobj, int rptnum, int period, int scope, int reset, int range, int start, int end, int suppress);
and the C declaration:
extern "C" DLLIMP_DBI char* __cdecl DisplayReport(int rvc, int wsobj, int rptnum, int period, int scope, int reset, int range, int start, int end, int suppress)
I'm assuming that the attempt to append more than 4k in a single string operation blows something up somewhere. At this point it's the only logical explaination I have.
Is there any way other than modifying the report to get the larger reports back? Since there is no way to just take the char* and work with it, I can't think of a way other than changing the DLL to use multiple calls to pull the data back in chunks.
Thanks in advance!
|
|
|
|
|
Mark Tutt wrote: char* __cdecl DisplayReport
Shoot the person that wrote that function, shoot him dead. People like that should not be allowed behind a keyboard. Suggest to him in a nice way that he should join the police academy.
Alternatively if you run out of bullets, or dont have any handy, try the StringBuilder class instead.
The correct way would be to get the value for that char*, then do Marshal.PtrToString , then pray the person that wrote the DLL used the default malloc/free mechanism. PInvoke free() passing the char* to prevent memory leaks.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
leppie wrote: Shoot the person that wrote that function, shoot him dead. People like that should not be allowed behind a keyboard. Suggest to him in a nice way that he should join the police academy.
Alternatively if you run out of bullets, or dont have any handy, try the StringBuilder class instead.
Now now, the DLL in question is part of a legacy codebase that goes back nearly 15 years, and is pretty much exclusively C/ASM. Gotta give a little respect to the people who wrote the stuff that the world runs on.
I'll take a look at Marshal.PtrToString...
|
|
|
|
|
Mark Tutt wrote: pretty much exclusively C/ASM.
Even for C that is bad.
Mark Tutt wrote: Gotta give a little respect to the people who wrote the stuff that the world runs on.
Now I'm getting more worried...
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi all, I'm new to this forum and to c# and my first project is a simple calendar for my tablet pc. In this project I dynamicly create buttons based on current month, looks like this:
private void createButtons()
{
int xet;
int numFirstDay;
DateTime myDateTime = new DateTime(activeYear,activeMonth,1);
if(myDateTime.DayOfWeek==DayOfWeek.Monday)
{
//functions for checking witch day in week the first day is }
int yet=569; int numdays =
DateTime.DaysInMonth(activeYear,activeMonth);
for(int i=1; i350)
{
yet+=20;
xet=16;
}
p.Y=yet;
p.X=xet;
aButton.Location=p;
aButton.Width=50;
aButton.Height=20;
aButton.Tag=i;
aButton.Name="button"+i;
aButton.Text=i.ToString();
if(i==activeDay)
{
aButton.BackColor = System.Drawing.SystemColors.ControlDark;
}
aButton.Click+=new EventHandler(aButton_Click);
this.Controls.Add(aButton);
xet+=50;
}
showDate();
}
This works fine and the buttons works as planned, now to my problem. When I change month from current to upcoming or earlier I like to relocate the buttons (x and y value) and hide for example button 31 if the next month only has 30 days. But I don't know how to adress these buttons from other functions?
Best Regards
Magnus
|
|
|
|
|
hi there,
mwallon wrote: But I don't know how to adress these buttons from other functions
Just suggest: whenever u create a button, u should store it into an arraylist
So u should be able to reference to the button via arraylist
<< >>
|
|
|
|
|
I assume you're missing a aButton = new Button(); from your code somewhere?
If you are dynamically creating buttons in your loop you will need to keep a reference to them to be able to access them again. Putting them in an ArrayList is usually a good solution. Another way to do it would be to iterate through your form's ControlCollection and find your buttons again which is also an option, but if you have a lot of other controls it isn't very efficient. Another alternative would be to add a group box or a panel to your form and put all your buttons in there.
|
|
|
|
|
Yes Wjousts you are right that line disapeard for some reason while I pasted the code.
The arrayList sounded very good but I didn't realy got it to work.
I just triead a simple thing like hidding one button:
btnList[1].Visible=false;
but got an error message saying:
'Object does not contain a definition for visible'
I created the list like this:
ArrayList btnList = new ArrayList();
and add buttons to it like this:
btnList.Add(aButton);
|
|
|
|
|