|
Hi, I develop an ERP from my company and now I've got a strange error:
"Assembly.createInstance contructor not found"
the error occurs in the code below:
<br />
Assembly asmForm;<br />
asmForm = Assembly.LoadFrom(MyLib.dll);
<br />
myOther Other = new myOther();<br />
<br />
Other.Name = "Walter";<br />
<br />
Form obj; <br />
obj = (Form)asmForm.CreateInstance("cForms.frmClass",<br />
true,<br />
BindingFlags.Public | BindingFlags.CreateInstance,<br />
null,<br />
new object[] { (Other) },<br />
System.Globalization.CultureInfo.CurrentCulture,<br />
null);<br />
<br />
((Form)obj).Show();<br />
Form will be load Dynamic
<br />
namespace cForms<br />
{<br />
public partial class frmClass : Form <br />
{<br />
<br />
public frmLista(myOther Other)<br />
{<br />
} <br />
Other Class
<br />
namespace cForms<br />
{<br />
public class myOther<br />
{<br />
public string Name;<br />
}<br />
}<br /> e;
}
}
-- modified at 14:09 Wednesday 30th August, 2006 e;
}
}
|
|
|
|
|
Hello,
I think you just have to add a default constructor to your class.
Walter O Dias wrote: I've got a strange error:
"Assembly.createInstance contructor not found"
Hope that means "constructor".
If yes, you just add.
namespace cForms<br />
{<br />
public partial class frmClass : Form <br />
{<br />
<br />
public frmClass()<br />
{<br />
}<br />
<br />
public frmLista(myOther Other)<br />
{<br />
}
Hope thats it!
All the best,
Martin
|
|
|
|
|
I put but, same error occurs.
Now I try to use Generics (Activator.CreateInstance<>) work fine, but i not have the implementation with parameters!
|
|
|
|
|
Hey,
I have a hashtable containing 100 images. When I try to serialize this down a network stream I get a 'Internal GDI+ error". The code looks something like this:
<br />
BinaryFormatter bf = new BinaryFormatter();<br />
bf.serialize(_Stream,_Images);<br />
Any ideas?
Many Thanks
Tom
|
|
|
|
|
Hi ALl,
I have developed a control library, and am running into some problems with serialization. When trying to serialize one of my controls, the serializer complains when it runs into something like the following:
[Serializable]
public class Control
{
public ContextMenu {get{...} set{...}}
}
So, the ContextMenu class is not serializable. If I try something like this:
[Serializable]
public class Control
{
[NonSerialized]
public ContextMenu {get{...} set{...}}
}
I will get another error that the NonSerialized attribute is only for fields or something. Apparently this only works for simple types, ie int's, strings? Is there another attribute to tell it to ignore a certain property when serializing?
Thanks in advance
|
|
|
|
|
Hi all,
First of all, please look at the following image:
http://img171.imageshack.us/img171/6038/graphne9.jpg[^]
I'm currently working on a reporting system for our web stats system.
Code:
Pen Black = new Pen(Brushes.Black, 1);<br />
Pen Gray = new Pen(Brushes.LightGray, 1);<br />
Bitmap b = new Bitmap(parentWidth,parentHeight);<br />
Graphics g = Graphics.FromImage(b);<br />
<br />
g = GenerateBG(g, parentWidth, parentHeight);
<br />
int width = parentWidth - 50;
int height = parentHeight - 50;
<br />
int spacer_width = width/7;
int spacer_height = 0;<br />
<br />
int maxCount = 0;<br />
<br />
ArrayList Data = new ArrayList();<br />
<br />
<br />
<br />
for(int i = -6; i < 1; i++)<br />
{<br />
DateTime date = DateTime.Now.AddDays(i);<br />
string toWrite = date.Day.ToString() + "/" + date.Month.ToString();<br />
g.DrawString(toWrite, new Font("Verdana", 7), Brushes.Black, ((i+7)*spacer_width), parentHeight -20);<br />
object[] dateData = dal.getStatsForDate(date.Date);<br />
if(dateData.Length > maxCount)<br />
maxCount = dateData.Length;<br />
Data.Add(dateData);<br />
}<br />
<br />
spacer_height = (height/maxCount);
<br />
int tempHeight = parentHeight;
<br />
int modCheck = Isqrt(maxCount);
<br />
for(int i = 0; i < maxCount; i++)<br />
{<br />
if((i%modCheck)==0)
{<br />
g.DrawLine(Gray, 50, tempHeight-25, width+25, tempHeight-25);
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-32);
}<br />
tempHeight = (tempHeight-spacer_height);
}<br />
<br />
g.DrawLine(Black, 50, 25, 50, parentHeight-25);
g.DrawLine(Black, 50, parentHeight - 25, parentWidth-25, parentHeight-25);
Now if you look at the image and the code, i've got something wrong and I can't figure where.
Basically, I have calculated the distance between each number/guide line by deviding the height by the maximum number which will be shown.
For some strange reason, it is not using the whole height of the grid.
Anyone have any idea why?
|
|
|
|
|
could you check the maxCount variable for its value? it seems like its value is too big.. like 2 times bigger than it should be...
On the other hand i don't know the value of ParentHeight so it could be possible that you're calculating with a wrong value all the time...
what exactly is that "dal" object you're using? What exactly does the getStatsForDate method and are you sure its outpu is correct?
|
|
|
|
|
maxCount will currently read 90.
parentHeight = 200
parentWidth = 700
dal is my data access layer, and getStatsForDate will take a date, and get all records in the database against this date.
maxCount will start off life as zero, and each time I loop through the dates, and retrieve the
data via getStatsForDate, I check the length to see how many rows were returned. If the amount of rows returned is more then the current value of maxCount, maxCount will change to the amount of rows.
Thanks for replying.
|
|
|
|
|
I think I may have sorted it.
rather then using the maxCount to calculate the space between lines etc, I have got the square root of the maxCount and devided that by the height.
Regardless of the maxCount value, it seems to be sticking in the correct place.
Thanks
|
|
|
|
|
Okay, i think i know the error now. You want the value 81 to be on the top of the graphic (almost y = 0??). if so, the problem is the height calculation.
add 2 variables
int dlHeight =
int dsHeight =
just replace this piece of code
<br />
spacer_height = (height/maxCount);
<br />
int tempHeight = parentHeight;
<br />
int modCheck = Isqrt(maxCount);
<br />
for(int i = 0; i < maxCount; i++)<br />
{<br />
if((i%modCheck)==0)
{<br />
g.DrawLine(Gray, 50, tempHeight-25, width+25, tempHeight-25);
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-32);
}<br />
tempHeight = (tempHeight-spacer_height);
}<br />
with this one
<br />
int tempHeight = parentHeight;
<br />
int sqrtMaxCount = Isqrt(maxCount);<br />
int rowHeight = height / sqrtMaxCount;<br />
<br />
for(int i = 0; i < sqrtMaxCount; i++)<br />
{<br />
g.DrawLine(Gray, 50, tempHeight-rowHeight, width+25, tempHeight-rowHeight);<br />
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-rowHeight-7); <br />
<br />
tempHeight -= rowHeight;
}<br />
in case you haven't found it out yourself yet
I hope i didnt miss anything - currently i'm too lazy to write it myself but if it doesn't work i'll give it a try
*edit* i forgot to change the condition for the for-loop... that would have turned out bad!
|
|
|
|
|
I have recently determined that it would be really convenient to add a button to the ControlBox in a 2.0 app. is there a way to add a button next to the minimize, maximize and close buttons up in the controlbox?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
I've never seen something like this (except for this "minimize to tray" button) and guess its not possible via managed code. You probable have to use the windows api to do it (if it's even possible).
|
|
|
|
|
Hi All,
I can allocate 400 Mb of memory in 2 steps:
int[] values1 = new int[1024*1024*200];
int[] values2 = new int[1024*1024*200];
However I can not allocate this amount of memory in one step:
int[] values1 = new int[1024*1024*400];
This is because of OutOfMemoryException.
I also mention that I can easily allocate 800 Mb of memory in my C++ application.
What could be wrong in .NET memory allocation?
Thanks,
Pawel
|
|
|
|
|
i'm not sure if i am right but:
an int32 wont hold more than about 4.000.000.000 (somewhere "near" that)
1024*1024*200 will result more than 20.000.000.000 so you should try to use
1. unsigned variables
2. bigger variables
the last time i had to use 64-bit variables, they were no operators for multiplications and division available so you will have to "work around".
|
|
|
|
|
mikone wrote: 1024*1024*200 will result more than 20.000.000.000
;P
|
|
|
|
|
uhh yeah, excuse me. i was at work so my brain was kinda turned off
so yeah, that definitely would fit an 32-bit integer (200.000.000)
next time i should use a calculator just to make sure such an emberassing thing doesn't happen again (but as i already said: i was at work, you can't blame me )
|
|
|
|
|
I put the wrong code in the post. This is what I was thinking about:
it works:
int[] values1 = new int[1024*1024*50]
int[] values2 = new int[1024*1024*50]
it gives OutOfMemoryException:
int[] values1 = new int[1024*1024*100]
There is enough free memory to allocate even 1Gb, but the problem for .NET is that there is no continous area of the memory which size is 400Mb. This is why I can allocate two times 200Mb but I can not allocate 400 Mb once. The question is: Can it be avoided somehow?
pawelpus
|
|
|
|
|
there is another answer to this question already - i will sum it up:
you're creating an array of integers whichs elements are 4 byte big. thats why you should change it to
<br />
byte[] values = new byte[1024*1024*100];<br />
|
|
|
|
|
Hi,
byte[] values = new byte[1024*1024*100]
The above code line needs 100 Mb of the memory
int[] values = new byte[1024*1024*25]
The above code line needs 100 Mb of the memory.
The point is that I can not allocate on my machine 400 Mb in any way.The code with byte[]..gives the same resuls as the code with int[]..
pawelpus
|
|
|
|
|
<br />
byte[] values = new byte[1024*1024*1231];<br />
Console.WriteLine(values.Length.ToString());<br />
Console.ReadKey(); <br />
this code produces the following output:
<br />
1290797056<br />
when i tried
<br />
byte[] values = new byte[1024*1024*1231];<br />
the same exception occured.
that means i was able to allocate 1231 mb...
|
|
|
|
|
On my machine both are giving me an OutOfMemoryException.
Integers have 4 Bytes so int[] values1 = new int[1024*1024*400]; will allocate not 400 MB but 1600MB. The logical memory limit of Windows 32 bit per process is somewhere near 2GB and I think .Net crunches away some of this.
Thus you are really reaching the limit...
|
|
|
|
|
I put the wrong code in the post. This is what I was thinking about:
it works:
int[] values1 = new int[1024*1024*50]
int[] values2 = new int[1024*1024*50]
it gives OutOfMemoryException:
int[] values1 = new int[1024*1024*100]
There is enough free memory to allocate even 1Gb, but the problem for .NET is that there is no continous area of the memory which size is 400Mb. This is why I can allocate two times 200Mb but I can not allocate 400 Mb once. The question is: Can it be avoided somehow?
pawelpus
|
|
|
|
|
An int is 4 bytes. It is a synonym for Int32 . Thus you are allocating ~1.6Gb.
Try creating a byte[] instead
|
|
|
|
|
I put the wrong code in the post. This is what I was thinking about:
it works:
int[] values1 = new int[1024*1024*50]
int[] values2 = new int[1024*1024*50]
it gives OutOfMemoryException:
int[] values1 = new int[1024*1024*100]
There is enough free memory to allocate even 1Gb, but the problem for .NET is that there is no continous area of the memory which size is 400Mb. This is why I can allocate two times 200Mb but I can not allocate 400 Mb once. The question is: Can it be avoided somehow?
pawelpus
|
|
|
|
|
I would like to make an exe dependent on another exe i.e when program a.exe is started program b.exe should also start and when program a.exe terminates program b.exe should also terminate.
Is that possible?
How could I make it happen?
|
|
|
|