|
As CG said, you will have to create a C++ DLL that exposes your classes/interfaces. Once you have the DLL, you can consume it from your C# project.
Cheers,
Vikram.
"But nowadays, it means nothing. Features are never frozen, development keeps happening, bugs never get fixed, and documentation is something you might find on wikipedia."
- Marc Clifton on betas. Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
ok....I understood that....but I don't know how to do this dll....can you help me...please
|
|
|
|
|
Hey guys
I am trying to create an install file for my solution. My solution has five projects, four of which are business layers and data access layers. The UI project has references to the debug dll's of the other projects and all works fine in debug mode. However when I build the setup project and run it on another computer it is still trying to reference the debug dll's rather than those installed. What am I doing wrong? I thought the setup project automatically changed these references!? I am using the setup wizard project to create the relevant files.
Thanks in advance
|
|
|
|
|
I am pretty sure that the setup project only points to the dlls you tell it to include. I am pretty sure you need to remove the old debug dlls from the setup and add the new release dlls.
Ben
|
|
|
|
|
Ben is absolutely right and just want to add one more thing make sure u have taken all resources
with the setup used by released Dlls
Cheers
Anuj
|
|
|
|
|
How to read image file ? I want read a image file, output is 3 matrix 2x2 following R G B? Help me!!!
ok
|
|
|
|
|
To read a bitmap
Bitmap bm = Bitmap.FromFile("myfile.jpg") or Bitmap bm = new Bitmap("bm.tif");
To read the RGB values, read my image processing articles on this site.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Could someone give me a link or a couple to some good articles on MFC serialization?
Thanks in advance!
Keshav Kamat
India
|
|
|
|
|
Keshav V. Kamat wrote: Could someone give me a link or a couple to some good articles on MFC serialization?
I don't know of any. But I'm sure the good folks in the C++ / MFC[^] forum would!
|
|
|
|
|
Hey guys,
I'm writing a piece of software which requires to monitor the CD Tray for discs.
<br />
foreach (DriveInfo drvInfo in DriveInfo.GetDrives())<br />
{<br />
if (drvInfo.DriveType == DriveType.CDRom)<br />
{<br />
if (drvInfo.IsReady)<br />
btnStartUpdateProcess.Enabled = (drvInfo.RootDirectory.GetFiles("*.enc").Length > 0);<br />
else<br />
btnStartUpdateProcess.Enabled =false;<br />
}<br />
}<br />
The code is called by a timer's Tick event. Now when I start the application with a disc in the drive, the code works fine. When I eject the disc, the button btnStartUpdateProcess gets disabled as soon as the timer fires the tick event. The button also enables again when a disc in inserted with at least one file in the root, with the .enc extension.
However, when I start the application with no CD in the tray the button starts disabled (which is correct) but when inserting a disc, the IsRead will return false over and over again. It looks like the IsReady value doesn't update or so. When I stop the application and imidiately start it again (not touching the CD Tray, the IsReady property returns true again.
Is my approach for 'monitoring' the CD incorrect or something?? I've also used some (WMI based) monitors (downloaded) which fire Insert and Eject events, but the result is the same. It seems like some kind of misterious lock prevents my app from detecting discs.
|
|
|
|
|
Is it possible to create an instance of a class under one button and use it in another button.
Well basically what i am trying to do is
I am writing an application which control the execution of command over local and remote machine.
So i want to use 3 buttons i.e. Register , Submit and Unregister.
Now under Register button i simply want to create an instance of a class which in turns goes to register function with in that class.
handle han = new handle("MyProgram"); // here my program gets registered.
Now i want to use han object over another button i.e submit button, somethin like that/
han.submit(...);
So is there any way to do so. I dont think its a good idea to create instance of a class globally because whole thing is that i want to make use of register button n so on.
Thanks
SS
|
|
|
|
|
Software_Specialist wrote: Is it possible to create an instance of a class under one button and use it in another button.
Yes.
Software_Specialist wrote: So is there any way to do so. I dont think its a good idea to create instance of a class globally because whole thing is that i want to make use of register button n so on.
You can store it as a field on the Form class.
|
|
|
|
|
sorry but could you tell me via giving example how to store it as field.
Bit new to windows programming.
Thanks
|
|
|
|
|
Software_Specialist wrote: how to store it as field
AKA Member variable
public class MyForm : Form
{
private MyObject someObject;
...
public void TheRegisterMethod()
{
this.someObject = new SomeObject("blah");
}
...
public void SomeOtherMethodThatNeedsSomeObject()
{
this.SomeObject.DoStuff();
}
}
|
|
|
|
|
You var must be a so called class member
class a
{
private YourClass ycInstance = null;
private void btn1_click(object sender, eventargs e)
{
ycInstance = new YourClass();
}
private void btn2_click(object sender, eventargs e)
{
ycInstance.DoWork();
}
}
.: I love it when a plan comes together :.
http://www.zonderpunt.nl
|
|
|
|
|
OK, the best advice I can give you is to buy a book and work through it, so that you have some basics as a starting point for the questions you ask here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
yeh gt it working now. Well book idea is not bad actually. I got few books but none of them explain anything about windows programming. But anyway i know what i asked, it was just i couldnt got him in beginning.
Thanks
|
|
|
|
|
Hi all, I have two questions pertaining to accessor methods in classes. I'm hoping someone can help.
Question 1: How do you write get and set methods for a member variable that is an array? I'll use a simple example to explain what I'm trying to achieve.
class MyClass
{
public int MyInt1;
public int MyInt2;
public int MyInt3;
public int[] MyIntArray;
{
get
{
int[] tmparray = new int[3];
tmparray[0] = MyInt1;
tmparray[1] = MyInt2;
tmparray[2] = MyInt3;
return tmparray;
}
set
{
MyInt1 = value[0];
MyInt2 = value[1];
MyInt3 = value[2];
}
}
public MyClass()
{
MyIntArray = new int[3];
}
}
In plain English, this is a class that has three member variables of type int and an additional member variable of type int[] which I'm hoping to map to the three member variables through accessor methods so that the three member variables of the class can be obtained and modified in an int array. This is how I'm hoping to do it:
MyClass MyInstance = new (MyClass);
int[] SomeArray = {10, 20, 30};
MyInstance.MyIntArray = SomeArray;
MyInstance.MyIntArray[1] = 40;
Note 1: At this stage everything work as expected and the three int member variables (MyInt1, MyInt2 and MyInt3) have the values 10, 20 and 30 respectively.
Note 2: The problem comes when I'm trying to set only certain elements in the array. I would expect that, at this point, the three int member variables would hold the values 10, 40 and 30 but the set method is never called when I allocate a value to an individual element in the array as done here.
Does anyone know how to write the get and set methods so that the array can be accessed both as an entire array or as individual elements?
Question 2: Can get and set metods be virtual (or something similar)? What I'm hoping to do is to put the MyIntArray member variable in a base class from which other classes inherit and then write the actual get and set methods in the inheriting classes rather than in the base class. Again, here is a simple exaple of what I'd like to do.
class MyBaseClass
{
public virtual int[] MyIntArray;
public MyBaseClass()
{
MyIntArray = new int[3];
}
}
class MyClass : MyBaseClass
{
public int MyInt1;
public int MyInt2;
public int MyInt3;
public int[] MyIntArray;
{
get
{
int[] tmparray = new int[3];
tmparray[0] = MyInt1;
tmparray[1] = MyInt2;
tmparray[2] = MyInt3;
return tmparray;
}
set
{
MyInt1 = value[0];
MyInt2 = value[1];
MyInt3 = value[2];
}
}
}
This doesn't work. It doesn't even compile and I'm not entirely surprised. But is there a way of doing what I'm trying to do here?
Thanks in advance.
|
|
|
|
|
Question 1:
Make the variable "tmparray" private to the class like this
class MyClass
{
public int MyInt1;
public int MyInt2;
public int MyInt3;
private int[] tmparray;
public int[] MyIntArray
{
get
{
tmparray = new int[3];
tmparray[0] = MyInt1;
tmparray[1] = MyInt2;
tmparray[2] = MyInt3;
return tmparray;
}
set
{
MyInt1 = value[0];
MyInt2 = value[1];
MyInt3 = value[2];
}
}
public MyClass()
{
MyIntArray = new int[3];
}
}
Question 2:
declare the property in the base class and then use the "new" keyword in the sub class on the same property.
class MyBaseClass
{
public int[] MyIntArray
{
get
{
}
set
{
}
}
public MyBaseClass()
{
MyIntArray = new int[3];
}
}
class MyClass : MyBaseClass
{
public int MyInt1;
public int MyInt2;
public int MyInt3;
private int[] tmparray;
public new int[] MyIntArray
{
get
{
tmparray = new int[3];
tmparray[0] = MyInt1;
tmparray[1] = MyInt2;
tmparray[2] = MyInt3;
return tmparray;
}
set
{
MyInt1 = value[0];
MyInt2 = value[1];
MyInt3 = value[2];
}
}
}
|
|
|
|
|
andre_swnpl wrote: Make the variable "tmparray" private to the class like this
That will have the same effect as before. It will not solve his problem as you never use tmparray so the value will never be properly reflected back into the object from which it came.
andre_swnpl wrote: declare the property in the base class and then use the "new" keyword in the sub class on the same property.
Don't do that either. Do it right by declaring the base as virtual or abstract then override it in the derived class.
|
|
|
|
|
Dewald wrote: The problem comes when I'm trying to set only certain elements in the array. I would expect that, at this point, the three int member variables would hold the values 10, 40 and 30 but the set method is never called when I allocate a value to an individual element in the array as done here.
That is correct. You only get the array. The accessing of the individual elements of the array is on the array that you have retrieved (an independent object that has no knowledge of how it was constructed or where it came from).
Also, because your array is being generated by the getter it is brand new and never stored anywhere. If you were to pass back an array that was stored as a field of the class then it would have the bahaviour you want. However, this is considered bad design as it breaks the encapsulation of the class (i.e. you can modify the contents of the class without the class knowing about it)
Dewald wrote: Does anyone know how to write the get and set methods so that the array can be accessed both as an entire array or as individual elements?
One possibility to get what you want AND keep good with OO is to write your own array class that understands where it came from and updates the source with its changes.
Dewald wrote: Can get and set metods be virtual (or something similar)?
I don't see why not.
Dewald wrote: This doesn't work. It doesn't even compile
You have provided no implementation in the base class. If you don't want to provide an implementation at that point you want to make it abstract .
Try something like this:
public abstract class A
{
public abstract int Property { get; set; }
}
class B : A
{
public override int Property
{
get
{
}
set
{
}
}
}
|
|
|
|
|
The problem with accessing the items as an array, is that you are working with an array that is a copy of the values. Changing the copy will not change the original values that the copy was created from.
You can either keep the data as an array and make properties to access the items separately, or keep the data separately and make an indexer to access them as an array.
public class ArrayStorageClass {
private int[] _data;
public ArrayStorageClass() {
_data = new int[3];
}
public int[] MyIntArray {
get { return _data; }
set {
if (value.Length != 3) throw new ApplicationException("An array with the size of three has to be used.");
_data = value;
}
}
public int MyInt1 { get { return _data[0]; } set { _data[0] = value; } }
public int MyInt2 { get { return _data[1]; } set { _data[1] = value; } }
public int MyInt3 { get { return _data[2]; } set { _data[2] = value; } }
}
ArrayStorageClass storage = new ArrayStorageClass();
storage.MyIntArray[0] = 42;
storage.MyInt2 = 1;
public class ArrayEmulatorClass {
private int _data1, _data2, _data3;
public ArrayEmulatorClass() {}
public int this[int index] {
get {
switch (index) {
case 0: return _data1;
case 1: return _data2;
case 2: return _data3;
default: throw new IndexOutOfRangeException();
}
}
set {
switch (index) {
case 0: _data1 = value;
case 1: _data2 = value;
case 2: _data3 = value;
default: throw new IndexOutOfRangeException();
}
}
}
public int MyInt1 { get { return _data1; } set { _data1 = value; } }
public int MyInt2 { get { return _data2; } set { _data2 = value; } }
public int MyInt3 { get { return _data3; } set { _data3 = value; } }
}
ArrayEmulatorClass emulator = new ArrayEmulatorClass();
emulator[0] = 42;
emulator.MyInt2 = 1;
If you want to declare the property in a base class without supplying the implementation, you can make it abstract. You also have to make the base class itself abstract, which means that you can't create instances of it. If you want to declare data in the base class to be used in the derived classes, make it protected.
public abstract class PropertyBaseClass {
protected int _data;
public abstract int MyProperty { get; set; }
}
public class SpecificPropertyClass : PropertyBaseClass {
public override int MyProperty { get { return _data; } set { _data = value; } }
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Fantastic! Thanks guys, you saved me a late night!
|
|
|
|
|
int s are value types. The int that is in tmparray[0] is different from the int that is MyInt1. Read up on value types and reference types.
Colin has answered Q2 very well, so I'll just skip that.
Cheers,
Vikram.
"But nowadays, it means nothing. Features are never frozen, development keeps happening, bugs never get fixed, and documentation is something you might find on wikipedia."
- Marc Clifton on betas. Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
Hi,
we are using vs 2005, for reporting purpose we are using .rdlc file. Here i want to set a parameter field, in design mode. pls help me in this regard
Selva..
|
|
|
|