|
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?
|
|
|
|
|
It is not possible, because may be the entry point of new dll file is not the same as older one!
Sojaner!
|
|
|
|
|
Hi everybody
I have a Word file with a picture inside which I saved as HTML filtered. I'm trying to send the Word file and have a little difficulty with it.
I know how to send a regular file but now I want to add to the email a picture which will be seen in the email and not as an attachment.
I know that I should use the "AlternateView" class and "LinkedResources" as the image but I don't know how to combine them together with the Word file itself.
Anybody did something like that or can direct me to a simple sample?
Another question: Is it possible to save a Word file that was opened for the first time and not saved as HTML filtered programmaticlly?
Thanks for any help
|
|
|
|
|
Hi,
I'm developing with Microsoft Visual Studio 2005 Version 8.
I want to create unit tests but can´t do so.
I don't have the new test option in the solution explorer.
Also, I can't add it as a project.
Don't know why, I have done it in other installations.
Do you know how can I add the possibility to create unit tests in C# in Visual Studio 2005?
Do I require the team edition?
Thanks
Martín
|
|
|
|
|
You need the Developer or Tester edition.
only two letters away from being an asset
|
|
|
|