|
What is the difference between the 'bin' and 'obj' directories in which your source files are located for VS.Net ?? It seems the contents are very similar (ie. an .exe file located in both locations after a build)
thanks in advance
Soliant
|
|
|
|
|
I believe the bin directory contains the final output, while the obj directory contains any temporary files (compiled .resources), vs.net temp files, and the like.
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
I am having quite a time trying to add a resource file to my project in
VS.NET. I've been scouring the help docs and I can't for the life of me figure out
what I'm doing wrong. Ideally, I'd like to find a link somewhere that walks me through, step by step, in creating a resource file (and explaining the advantage/disadvantages & difference in using a .resource or .resx file), adding it to your project and finally accessing the resources within that resource file.
Here's my issue... I have a resource file called Icons.resources (created with a freeware app I found... saves the resource as a .resource/resx file).
I have added it to my project and set it's properties to "Embedded
Resource"... but everytime I compile it, I get the following error:
Additional information: Could not find any resources appropriate for the
specified culture (or the neutral culture) in the given assembly. Make sure
"Icons.resources" was correctly embedded or linked into assembly "Picture
Utility".
baseName: Icons locationInfo: <null> resource file name: Icons.resources
assembly: Picture Utility, Version=1.0.783.28733, Culture=neutral,
PublicKeyToken=null
I have also been going through a program that does
the exact same thing I'm doing and can't seem to find the difference between
his and mine and what I'm doing wrong.
Thanks in advance
Andrew Connell
IM on MSN
andrew@aconnell.com
|
|
|
|
|
I got it... for those of you that have the same problems...
When I created my resource file ("Icons.resource") and added it to my project ("PictureUtility") as an embedded resource, I needed to access it by the name the project would understand... which is "PictureUtility.Icons".
Just posted by success story in case others have the same problem.
-AC
Andrew Connell
IM on MSN
andrew@aconnell.com
|
|
|
|
|
BTW, the prefix to access the file is actually the default namespace for the project. If you blank out your default namespace, you will then access the icon by just "Icons".
--
Peter Stephens
|
|
|
|
|
s = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp );
s.Bind(localEndPoint);
s.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.ReceiveTimeout,1000);
This code produces a runtime error:
An unknown, invalid, or unsupported option or level was specified in a getsockop
t or setsockopt call
Any help anyone ? I just want to set a timeout on recive of a UDP packet.
|
|
|
|
|
I believe it is because UDP doesn't support Timeouts, or so this thread on the Advanced DOTNET list seems to suggest.
Yes just when you thought I couldn't push the DOTNET mailing list anymore they make a new one!
Hope that thread gives you some ideas,
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
You are right, UDP is "connectionless", and because of that you can't set a timeout.
When you send UDP packets, you just send them, but you never know if the reciever get the packets or not...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Thanks, James, for the link to those two DotNet mailing lists. I'm already signed up!
--
Peter Stephens
|
|
|
|
|
Hi All,
Simple question here (I Hope)
I need to reset all my textboxes back to blank and am trying to do it in a nice clean loop.
I have the following but it does not work
foreach (TextBox t in this)
{
t.Text = "";
}
I am getting the error message
C:\Documents and Settings\gavin\My Documents\Visual Studio Projects\LTBRMaintenance\EditClinic.cs(487): foreach statement cannot operate on variables of type 'LTBRMaintenance.EditClinic' because 'LTBRMaintenance.EditClinic' does not contain a definition for 'GetEnumerator', or it is inaccessible
I have a feeling I am nearly there but am missing something obvious..
Thanks
|
|
|
|
|
I think that this is just an object and doesn't natively expose a GetEnumerator method. Try this:
foreach(Control c in this.Controls)
{
if(c.GetType().ToString()=="System.Windows.Forms.TextBox")
c.Text="new vlaue";
}
Cheers,
Simon
X-5 452 rules.
|
|
|
|
|
That is exactly it.
Thanks
|
|
|
|
|
simons wrote:
if(c.GetType().ToString()=="System.Windows.Forms.TextBox")
You could also use; if( c is System.Windows.Forms.TextBox ) this lets the value change for controls derived from TextBox too
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
James T. Johnson wrote:
if( c is System.Windows.Forms.TextBox )
That's a better way. Probably more robust too (if MS changes the text of class names).
Cheers,
Simon
X-5 452 rules.
|
|
|
|
|
I would like to set owner bgcolor while the user select an item in the treeview.
how do i do the work
|
|
|
|
|
Hi,
I have a c++ DLL it contains a class called MyClass with methods GetName and SetName.
[DllImport("MyClass.dll")]
public static extern void GetName( string name);
This doesn't work because I need to instanciate the class.
How do I declare the class and methods within the class?
Then how do I instancial the class and call the method?
Thanks
Mike
|
|
|
|
|
No way to do this from C#. Either use MC++, or wrap your class into a COM object and the reference it from your code.
I vote pro drink
|
|
|
|
|
Hello helpers.
So far, my asteroids game is coming along nicely, and I am learning lots. Now has come the time to get c# to play some sounds - by searching around I have found this:
[DllImport("winmm.dll")]
public static extern long PlaySound(String lpszName, long hModule, long dwFlags);
This does is fact work, however, the keener amongst you will realise that code execution stops until this function returns a value. Of course, in my game, I don't want the game to freeze everytime I call this function, so, is there
a) another method for playing a sound file (I used a com object in Foxpro) and if so, can somebody tell me how to do it in C#
b) a way to call PlaySound without waiting for a return value?
Many thanks you gorgeous hamsters
J
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
Use ASYNC flag that has a value 0x0001.
You can use enum to include other flags:
public enum PlaySoundFlag
{
// Play synchronously (default)
Synchronously = 0x0000,
// Play asynchronously
Asynchronously = 0x0001,
// Silence (!default) if sound not found
NoDefault = 0x0002,
// pszSound points to a memory file
Memory = 0x0004,
// Loop the sound until next sndPlaySound
Loop = 0x0008,
// Don't stop any currently playing sound
NoStop = 0x0010,
// Don't wait if the driver is busy
NoWait = 0x00002000,
// Name is a registry alias
Alias = 0x00010000,
// Alias is a predefined ID
AliasId = 0x00110000,
// Name is file name
Filename = 0x00020000,
// name is resource name or atom
Resource = 0x00040004,
// Purge non-static events for task
Purge = 0x0040,
// Look for application specific association
Application = 0x0080
}
Example:
PlaySound("c:\\windows\\media\\Windows XP Startup.wav",0,PlaySoundFlag.Filename|PlaySoundFlag.Asynchronously);
Should work
Jerzy
|
|
|
|
|
Or you could use an Asynchronous method call or make your synchronous call on a different thread.
--
Peter Stephens
|
|
|
|
|
Thanks for the advice. I will try to figure out how to make an asynchronous call - I assume this would be different to the flags that Jerzy is talking about?
Thanks though, will look into it.
Jase
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
Asynchronous calls in .NET use delegates. There are methods on a delegate called BeginInvoke and EndInvoke. I personally have not used async calls yet, but plan to do so soon.
AFAIK .NET async calls use a threadpool behind the scenes.
--
Peter Stephens
|
|
|
|
|
Thanks alot, that's a whole lot of detail. The example clinches it. You are the man .
Cheers
J;)
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
Hey Jerzy,
I tried this, but for some reason, none of the flags I pass in seem to make any difference. The sound does play though. Also, for some reason, when I use the enums as per your example, the code won't compile. I have tried subsituting the enums in the example for their values, but still things don't go according to my expectation (ie, makes no difference).
Does this declaration look right for c# to you?
public static extern long PlaySound(String lpszName, long hModule, long dwFlags);
As far as I understand it, my alternatives are:
1. no sound at all
2. use a com object as per my original fox pro code
3. for every sound played, create a new thread, play the sound, kill the thread
4. do some asynch calls with beginInvoke and delegates and stuff.
Don't want to do 1., 2. seems a good thing to learn in c#, in fact as does 3 and 4.
4 however I will have to leave until I have learnt a whole lot more or until someone explains the whole delegate thing to me.
If you have any more suggestions along the lines of your original, or anything else for that matter, would love to hear 'em.
Jase
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I tested this code and it's working:
....
....
....
using System.Runtime.InteropServices;
public class Form1 : System.Windows.Forms.Form
{
public enum PlaySoundFlag
{
Synchronously = 0x0000,
Asynchronously = 0x0001,
NoDefault = 0x0002,
Memory = 0x0004,
Loop = 0x0008,
NoStop = 0x0010,
NoWait = 0x00002000,
Alias = 0x00010000,
AliasId = 0x00110000,
Filename = 0x00020000,
Resource = 0x00040004,
Purge = 0x0040,
Application = 0x0080
}
[DllImport("winmm.dll")]
public static extern int PlaySound(String pszSound, int hmod,PlaySoundFlag fdwSound);
public Form1()
{
....
....
....
PlayTest();
....
....
....
}
void PlayTest()
{
PlaySound("c:\\windows\\media\\Windows XP Startup.wav", 0,
PlaySoundFlag.Filename|PlaySoundFlag.Asynchronously);
}
Jerzy
|
|
|
|
|