|
I need to pass struct MyStruct to another assembly. Please help me and share the code also (if possible).
Thx
A
|
|
|
|
|
I'm not sure what you mean
Foo(MyStruct)
only two letters away from being an asset
|
|
|
|
|
Ok for example
1) I have one assemble say A where i have struct "Mystruct" as
struct Mystruct(
int i;
int j;}
2)Now i am consuming method of another assembly in assembly A
dim myobj as new MyObj
myobj.Calc()
Now calc expects structure ...So how i can pass it?
A
|
|
|
|
|
As long as the assembly B has a reference to Assembly A, for MyStruct
myobj.Calc(struct)
What are finding difficult about this?
only two letters away from being an asset
|
|
|
|
|
getting type expected
Can you share simple source code for both the assempblies....It would be gr8 help....Just very simle code in C# for CLass A and B....
|
|
|
|
|
I'm a beginner in C# and I tried to make a console program where you enter a number, then the program tells you if your guess was too low or high, and you keep guessing until your guess is correct. I really thought that my code would work, but it doesn't. Can anybody please guide me in the right direction?
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
Random a = new Random();<br />
int counter = 0;<br />
int guess;<br />
int rand = 0;<br />
rand = (int) a.Next(0,10);<br />
<br />
Console.Write("Enter your guess: ");<br />
guess = Console.Read();<br />
<br />
while(guess != rand)<br />
{<br />
if(guess > rand)<br />
{<br />
Console.WriteLine("Wrong number, you aimed too high");<br />
}<br />
<br />
if(guess < rand)<br />
{<br />
Console.WriteLine("You aimed too low");<br />
}<br />
<br />
Console.Write("Please guess again: ");<br />
guess = Console.Read();<br />
counter++;<br />
}<br />
<br />
Console.WriteLine("Congratulations, you rock!");<br />
Console.WriteLine("It took you {0} tries", counter);<br />
}<br />
}<br />
}
|
|
|
|
|
Husker47 wrote: my code would work, but it doesn't
???
|
|
|
|
|
Your problem is with the call to Console.Read() - the integer that it returns is the Ascii value of the first character entered by the user. Use this instead:
int.TryParse( Console.ReadLine(), out guess);
The call to Console.ReadLine() reads the entire line of input supplied by the user, and then int.TryParse() attempts to parse that string into an integer value. TryParse returns a bool to let you know if the string could be parsed correctly or not. You'll probably want to add some error handling for when the user enters something that isn't a valid integer value, but that's totally up to you.
|
|
|
|
|
Thank you so much for your help, it works just as I hoped.
|
|
|
|
|
Glad to help
|
|
|
|
|
hello
has anybody tried to deselect a row of the datagridview?
i try to deselect a row, but the rowheader ALWAYS indicates a select row,
i aleady tried to use:
ClearSelection()
.Selected = false;
but nothing works. the "highlight" in the row disappears, but the rowheader indication not. then, if I try to verify the row to select it again, it never works, because the row is always selected.
anybody knows the solution?
thanks a lot again
|
|
|
|
|
Try:
Grid.MultiSelect = false; // surely clear all selections
Grid.MultiSelect = true; // return Grid state back
|
|
|
|
|
I am working on a project that needs plug-ins. For a proof of concept, right now I have a plugins folder where the dll files will reside. I created a class that compiles to a dll (simple class with no references). At runtime the program properly finds and constructs the class.
My Problem:
I have a new plugin project (project "a") that has a reference to an outside project (project "b". When project a compiles, all dll files from project b are in the same folder. When my main program calls the GetTypes() on the dll from project "a", 2 types come up: the base class from which project "a" was created, a type from a dependency on project "b". When I try to construct the type of project "a", i get an error:
"InnerException = {"Could not load file or assembly 'ProjectB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"ProjectBoardLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}"
How do I dynamically load a dll file that depends on outside dll files? Here is a snippet of my code:
foreach (Type t in asm.GetTypes())
{
if (t.BaseType.ToString() == "ProjectA.PageBase")
{
return (PageBase)t.GetConstructors()[0].Invoke(new object[] { });
}
}
|
|
|
|
|
I think the libraries the plugin depends on should be GAC'ed.
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
if i am getting this error, whats the next step? I don't think they are getting cached.
|
|
|
|
|
You should show us the code that actually (attempts to) load the DLLs.
|
|
|
|
|
Assembly ass = Assembly.LoadFile(path);
foreach (Type t in ass.GetTypes())
{
if (t.BaseType.ToString() == "MadPages.PageBase")
{
return (PageBase)t.GetConstructors()[0].Invoke(new object[] { });
}
}
|
|
|
|
|
|
thanks for the post, it did help a portion.
I ran into a new problem. My Assembly class also implements an interface. When I try to cast the object to the type of the interface, i get this exception:
The type 'ProjectA.PageBaseOperations' exists in both '{9491320D-D340-4DBD-9D31-99B6FDD80C76}' and '{0EDD5000-CA92-4762-A84D-5F68E055ECCE}'
|
|
|
|
|
Hello,
does somebody know, how to play a mp3 file from stream? not from a file!
AudioVideoPlayback can only play files.
DirectSound is not able to play mp3, but it can open streams..
thanks!
Dirk
|
|
|
|
|
Hope the Article by Giorgi Dalakishvili Here[^] will help you.
And also the article by Kareem Ali Saving from a Stream to a file[^].
Hope this both article will help you and i think if you create the Stream as an exe file means you can run it otherwise you cannot.
Regards,
Satips.
|
|
|
|
|
This is not what I'm looking for...
Its a continous stream from the internet...
|
|
|
|
|
|
The code runs in the thread that called it. If the UI thread called the code, then it runs in the UI thread. If it's called by a child thread, then it runs in the child thread.
|
|
|
|
|
I have an EXE (and not the source code).
And the EXE have a dll as reference to it?
Now I have another version of same dll (same name)
How to make the Exe to point to the newer version of the dll?
|
|
|
|