Click here to Skip to main content
15,886,693 members
Home / Discussions / C#
   

C#

 
GeneralRe: Crop a circle image from a square picture Pin
Babita Shivade21-Apr-09 2:06
Babita Shivade21-Apr-09 2:06 
GeneralRe: Crop a circle image from a square picture Pin
Skymir21-Apr-09 2:49
Skymir21-Apr-09 2:49 
QuestionC# -Savefile Dialog to save an image file Pin
vijaywithu21-Apr-09 0:30
vijaywithu21-Apr-09 0:30 
AnswerRe: C# -Savefile Dialog to save an image file Pin
OriginalGriff21-Apr-09 0:53
mveOriginalGriff21-Apr-09 0:53 
AnswerRe: C# -Savefile Dialog to save an image file Pin
Roman Lerman21-Apr-09 1:00
Roman Lerman21-Apr-09 1:00 
QuestionHow to fix the hight of footer control in Report Viewer(RDLC) asp.net Pin
Member 226432921-Apr-09 0:13
Member 226432921-Apr-09 0:13 
AnswerRe: How to fix the hight of footer control in Report Viewer(RDLC) asp.net Pin
Mycroft Holmes21-Apr-09 0:37
professionalMycroft Holmes21-Apr-09 0:37 
QuestionProblem loading assembly from byte[] Pin
Helfdane21-Apr-09 0:03
Helfdane21-Apr-09 0:03 
Hi,

I've got this issue with loading an assembly from a byte array.

What happens?
First I create an assembly from C#-code which is generated. Then I stream the assembly to a byte[] and store this array in the database (column type = image, MSSQL 2000).

When I need the assembly, I retrieve the byte[] from the db and want to load it. I try to load the assembly using Assembly.Load(array), and then it breaks. For some strange reason my VS decided to give me a Dutch error while my language is set to English:

{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Poging om een programma te laden met een onjuiste indeling."}

Which I think translates to:
{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."}

I'm having trouble finding a good solution for it, as I don't know where it goes wrong. It all happens in the same namespace, by the same package. So the creation, streaming and loading happens in the same dll.

Source I use is below:
public CompiledFormula GetCompiledFormula(string cstext)
{
// Create assembly by compile
Assembly ass = Compile(cstext);

CompiledFormula result = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");
return result;
}

The byte conversion as follows:
public byte[] GetArrayFromAssembly(Assembly formula)
{
byte[] assembly;

try
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = 
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

formatter.Serialize(stream, formula);
assembly = stream.ToArray();

}
catch(Exception ex)
{
throw ex;
}
}

And this is the loading routine:
public CompiledFormula LoadFormuleFromAssembly(byte[] array)
{
try
{
Assembly assembly = Assembly.Load(array);

CompiledFormula formule = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");

return formule;
}
catch (System.Exception ex)
{
throw ex;
}
}

Anyone has an idea? Also, tell me if I make a horrible mistake here Wink | ;)

The consumer isn't a moron; she is your wife.

AnswerRe: Problem loading assembly from byte[] Pin
Rob Philpott21-Apr-09 3:41
Rob Philpott21-Apr-09 3:41 
GeneralRe: Problem loading assembly from byte[] Pin
Helfdane21-Apr-09 3:53
Helfdane21-Apr-09 3:53 
Questionalternative to session use Pin
mudag21-Apr-09 0:00
mudag21-Apr-09 0:00 
AnswerRe: alternative to session use Pin
Le centriste21-Apr-09 1:15
Le centriste21-Apr-09 1:15 
GeneralRe: alternative to session use Pin
Ian McCaul21-Apr-09 4:48
Ian McCaul21-Apr-09 4:48 
GeneralRe: alternative to session use Pin
Le centriste21-Apr-09 5:44
Le centriste21-Apr-09 5:44 
Questionplaying multiple video files using axWindowMediaplayer tool !!! Pin
mist_psycho20-Apr-09 23:19
mist_psycho20-Apr-09 23:19 
AnswerRe: playing multiple video files using axWindowMediaplayer tool !!! Pin
Roman Lerman20-Apr-09 23:57
Roman Lerman20-Apr-09 23:57 
Questioncanvas.Focus does not unfocus textbox Pin
Pauwels Bart20-Apr-09 21:51
Pauwels Bart20-Apr-09 21:51 
AnswerRe: canvas.Focus does not unfocus textbox Pin
Roman Lerman20-Apr-09 22:35
Roman Lerman20-Apr-09 22:35 
GeneralRe: canvas.Focus does not unfocus textbox Pin
Pauwels Bart20-Apr-09 22:51
Pauwels Bart20-Apr-09 22:51 
Questionwhat does this error mean Pin
benson.misi20-Apr-09 21:47
benson.misi20-Apr-09 21:47 
AnswerRe: what does this error mean Pin
Pete O'Hanlon20-Apr-09 21:51
mvePete O'Hanlon20-Apr-09 21:51 
GeneralRe: what does this error mean Pin
CPallini21-Apr-09 2:11
mveCPallini21-Apr-09 2:11 
GeneralRe: what does this error mean Pin
Pete O'Hanlon21-Apr-09 2:24
mvePete O'Hanlon21-Apr-09 2:24 
AnswerRe: what does this error mean Pin
N a v a n e e t h20-Apr-09 21:52
N a v a n e e t h20-Apr-09 21:52 
QuestionHow to import following C DLL function to C# ? [ I am still waiting .... :( ] [Wating no more :)] Pin
Roman Lerman20-Apr-09 20:53
Roman Lerman20-Apr-09 20:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.