|
Yes, well, we were working with onsite Microsoft people. I had mission critical apps to work on and left all of the problem resolution to them. And while I use Google extensively for all types of searches, I usually do not do any searching of Google Groups.
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
Google Groups is your friend! I search it more often than the web when I have problems!
|
|
|
|
|
Hi,
I’m new to C# and the .NET world. Can anyone tell me how to create a master project populated with sub projects? Ideally I’d like to have my master project depend upon a couple sub projects (like a common library, user info, and database info). How can I create this structure in .NET? Once this structure is created, how do I add project dependencies?
If anyone can show me an example of this that would be great.
Thanks
|
|
|
|
|
If we're talking VS.NET, you should create a Solution to hold all these Projects. If you don't have a Solution open when you create a new project, VS.NET will create one for you.
When you select File > New > Project, the New Project dialog has a pair of radio buttons Add to Solution and Close Solution. Select Add to Solution to keep this project as part of the whole solution. If you have a project you want to add to an existing solution, choose File > Add Project > Existing Project.
To set up dependencies, use the Projects tab of the Add Reference dialog, rather than the .NET tab.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
To add to what Mike said, the reason you use Project references is because it automatically sets up build dependencies and uses the latest version of the dependent assemblies.
Also, in larger, multi-project solutions, DO NOT use automatic versioning (i.e., set AssemblyVersionAttribute so that it doesn't use an asterisk (*)). You can quickly loose control with versions being different, especially when multiple developers are working on the solution.
In .NET, version numbers matter. If you binding against assembly A, version 1.0.0.0, then when assembly B (has a dependency on A) loads, assembly A, version 1.0.0.0 better be there. You can use the .config file and the <assemblyBinding> section to redirect these versions or use a publisher policy (a specially named assembly that goes into the GAC), which is primarily for upgrading your application (so long as backward compatibility is maintained). You certainly don't want to have to worry about this when developing.
If you want to use automatic versioning, expect problems. You can get around them, however. Lets say that each developer has an application test directory (or even a shared one). Using the assembly A as a dependency of assembly B example (lets say B is a .exe), you could use a .config in the same directory as B.exe like this:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="A" publicKeyToken="0123456789abcdef"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535"
newVersion="1.0.1556.500"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> This will redirect the assembly binding from whatever version it is to version 1.0.1556.500, so make sure you update those config files when you drop a new version of assembly A in the app directory.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want add KeyUp event to columnStyle
How can I do that pls ?
thanx ..
|
|
|
|
|
columnStyle? Are you talking about the DataGridColumnStyle?
The DGColumnStyle class does not handle keyboard events since it never actually gets the input focus. These are handled by the DataGrid itself. What were you looking to do with KeyUp?
RageInTheMachine9532
|
|
|
|
|
thanx
yes I m talking about DataGridColumnStyle
this code is usefull to add KeyDown event
DataGridTextBoxColumn _datagridtextBox = (DataGridTextBoxColumn) CorpEc.TableStyles[0].GridColumnStyles[0];
_datagridtextBox.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(ID_KeyDown);
but I don't know why it doesn't work for kewUp
thanx
|
|
|
|
|
Hey
I have made an client that takes contact with the servern and verifie the user name and password, after this its loging in to the game.
I want to have an animation during contacting server on the front login form, tu it will not load in the gif animation?
I got one button ("LOGIN") this button is makeing a new connection
connection = new Connection(this,txtLoggInName.Text,txtLoggInPass.Text,txtLoggInIp.Text,txtLoggInPort.Text,b.Text);
in the connection contructer it uses this code
public Connection(Client newClient,string name,string pass,string ip,string port,string query)
{
try
{
client = newClient;
if(name==string.Empty)throw new System.FormatException("Username not supplied");
if(pass==string.Empty)throw new System.FormatException("Password not supplied");
name = username(name);
string strHost = string.Empty;
IPHostEntry IPHost = Dns.GetHostByName(strHost);
IPAddress[] IPAdr = IPHost.AddressList;
socket = new TcpClient(ip,Int32.Parse(port));
user = new Transfer.User(name,IPAdr[0].ToString());
password = new Transfer.Password(pass);
switch(query.ToLower())
{
case "login":
request = new Transfer.Database(Transfer.Database.Request.LOGIN);
break;
case "new player":
request = new Transfer.Database(Transfer.Database.Request.CREATE);
break;
}
running = true;
}
catch...........................
I have tried to load the gif picture, first of al in the login button that makes a new connection later on.
But it will not load it, the same is if i load in text to a label it will not load the text, i must just .refresh(); on the control then it draws the picture and set the text in the label. But it will not animate the Gif animation, it only shows the first pictur.
I have tried to start a high priority thread that shows picture after picture in a loop with .refresh() after every picture but this will not paint a singel frame even. this thread i starts in the begining of the login button and then starts before creating the new connection.
I have also tired to load in the gif animation before i hit the login button, and then the animation is playd as i shold, but as soon as i hit the login the animation stops.
Is there any way to fix this problem? it simes like the connection takes al the programs power.
//Snowman
|
|
|
|
|
It seems you're trying to set the image (or the text in a Label ) in a separate thread. You can't do this. You must set any properties that would change the UI in the thread in which the particular UI element was created. See Control.InvokeRequired and Control.Invoke for how to do this. You basically create a delegate to set the text or image or whatever and have the control invoke that delegate in its UI thread.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes but if we dont use threads at al, and just use the buttons funktion.
If we press the button we first of al load the gif animation in to the label och picturebox, then we goes on to creat the new connection.
And if i do this the Gif animation will not run at all, it will not even be loaded though it is set first in the button funktion and the connection creation is not until later in the button funktion.
If i whant it to load i have to use contrl.refresh(); and then it loads it, but jus the first frame int the gif.
//Snowman
|
|
|
|
|
Create your connection asynchronously. I'm not sure if the PictureBox animates a GIF in the same UI thread, but if it does it will most likely be lower in priority than the main execution of your code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am having trouble using OR in an If loop. I have
if (cboCeaseType.SelectedValue.ToString () == "2") or (cboCeaseType.SelectedValue.ToString () == "5" ){
do something
} else {
do something else
}
It doesn't like this. How do I have an OR in an If loop? What should the above be?
Cheers
Ian
|
|
|
|
|
You need to enclose the whole in brackets and the OR operator in C# is ||
(If you're curious the AND operator is &&)
Your code should look like this:
if ((cboCeaseType.SelectedValue.ToString () == "2") ||(cboCeaseType.SelectedValue.ToString () == "5" ))
I've underlined the changes.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Brillint, thanks for your quick responce. Saved me hours!
Ian
|
|
|
|
|
Also, you only need one set of brackets:
<br />
if (<br />
cboCeaseType.SelectedValue.ToString() == "2" || <br />
cboCeaseType.SelectedValue.ToString() == "5")<br />
The extra brackets are unnecessary (but won't do any harm).
|
|
|
|
|
*slap on the wrist*
It's about readability, my good man! Seperating those two conditionals with their own set of parens makes it clearer what is being compared.
Jeremy Kimball
Moderation is for monks. -Lazarus Long
And this, too, shall pass away...
|
|
|
|
|
Hi,
I would like to generate rtf code of the picture/image programatically without using richtext box or clip board.
To be more specific I want to create .rtf file of image/pictures ?
Need help in above regard......
Thanx in advance..
Regards,
Jay
|
|
|
|
|
In the RTF specification, pictures can be encoded using hexidecimal or binary encoding. If you use binary (hexidecimal is more common), do not use CR/LF pairs to break lines (as is usual with binary files).
Getting the hexidecimal value of bytes isn't hard. Just loop through the bytes and output base16 char sequences:
Image img = new Bitmap("myimage.bmp");
MemoryStream ms = new MemoryStream();
img.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
StringBuilder sb = new StringBuilder(ms.Length * 2);
byte[] buffer = new byte[4096];
int read = ms.Read(buffer, 0, buffer.Length);
while (read != 0)
{
for (int i=0; i<read; i++) sb.AppendFormat("{0:x2}", buffer[i]);
read = ms.Read(buffer, 0, buffer.Length);
}
string hex = sb.ToString(); It's not exactly the most efficient, but you should get the idea.
There are several sections require to embed a pictures in RTF. Read more about embedding pictures in the RTF specification at http://msdn.microsoft.com/library/en-us/dnrtfspec/html/rtfspec_16.asp?FRAME=true#rtfspec_24[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Steward,
Thanks a lot for the solution.
I have modified the code since there was some compilation error as below
<br />
string strfileName = "PicInHex.rtf";<br />
FileStream MyStream = new FileStream("c:\\" + strfileName, FileMode.Create);<br />
System.IO.StreamWriter MyWriter =<br />
new System.IO.StreamWrite(MyStream,System.Text.Encoding.Default);<br />
<br />
Image img = new Bitmap("myimage.bmp");<br />
MemoryStream ms = new MemoryStream();<br />
img.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);<br />
ms.Seek(0, SeekOrigin.Begin);<br />
StringBuilder sb = new StringBuilder(Convert.ToInt32(ms.Length * 2));<br />
byte[] buffer = new byte[4096];<br />
int read = ms.Read(buffer, 0, buffer.Length);<br />
while (read != 0){ <br />
for (int i=0; i<<read; i++)<br />
sb.AppendFormat("{0:x2}", buffer[i]); <br />
read = ms.Read(buffer, 0, buffer.Length);<br />
}<br />
string hex = sb.ToString();<br />
MyWriter.Write(hex);<br />
<br />
MyWriter.Close();<br />
MyStream.Close();<br />
I want to get the hex code of the image using the above code then prefix and suffix image rtf syntax in it to get rtf code file
when I try to open the "PicInHex.rtf" (created after executing the above code)using notepad to view the hex code. the NotePad application crashes.
Will you please commnet whether
1. can I open and view the code using notepad (the bmp is of A4 size)
2. Am I correct in approaching the solution?
Let me thank you once again for your co-operation and solution.
Regards,
Jay.
|
|
|
|
|
It was sample code - it wasn't meant to be complete, but to serve as an example.
Notepad is a vanilla (i.e., plain) text editor so it won't view anything for the RTF "code" itself. The image will appear as what it appears in the actual RTF: hex.
So long as your hex-encoding the image and using the right RTF codes, then there really is no other way to approach this without using some third-party library or some RTF control like the RichTextBox .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
public string ImageToRTF(Image img)
{
RichTextBox rtf = new RichTextBox();
Clipboard.SetDataObject(img);
rtf.Paste();
return rtf.Rtf;
}
|
|
|
|
|
Dear Heath Stewart and Gonzalez,
thanks a lot for the solution and guidance, it solves the purpose. I am pasting my complete Demo code.This can be helpful to another developers
private void button1_Click(object sender, System.EventArgs e)
{
string strImageToRTF ="";
string strfileName = "ImageInRTFfile.rtf";
FileStream MyStream = new FileStream("c:\\" + strfileName, FileMode.Create);
System.IO.StreamWriter MyWriter =new System.IO.StreamWriter(MyStream,System.Text.Encoding.Default);
Image img = new Bitmap(@"c:\myimage.bmp");
strImageToRTF = this.ImageToRTF(img);
MyWriter.Write(strImageToRTF);
MyWriter.Close();
MyStream.Close();
}
private string ImageToRTF(Image img)
{
RichTextBox rtf = new RichTextBox();
Clipboard.SetDataObject(img);
rtf.Paste();
return rtf.Rtf;
}
Thanks and Regards,
Jay.
|
|
|
|
|
I have created several new components that I have successfully added to the General tool bar. Method of building and using the new components is pretty much straight out of the C# Unleashed book. I can set the properties I have built into them and I get the expected results. I can compile, it works. Exit VS and run the executable and it still works as intended.
The problem is: Reload the project is VS (2003 edition) and any of the custom properties are reset back to the original defaults.
A property example would be:
<br />
...<br />
private InputMaskType maskType;<br />
public enum InputMaskType {None, Dollars, Percent, Phone}<br />
...<br />
[Description("Sets Predefined Input Mask"), Category("Behavior"),<br />
RefreshProperties(RefreshProperties.All)]<br />
public InputMaskType DisplayMaskFormat<br />
{<br />
get { return maskType; }<br />
set { maskType = value; }<br />
}<br />
...<br />
I haven't come across anything that indicates I have to do something different to store the properties permanently, but if so, please let me know.
|
|
|
|
|
Properties - and practically everything else you do in VS.NET (can't vouch for third-party controls written poorly) - are persisted to the source files, ResX files (localizable resource files), or other similar files. Everything you do in VS.NET can be done with command-line compilers. If you're loosing values when upgrading your projects, then it's usually because ResX files (where localized values may be stored) are referencing older versions of assemblies (most likely FCL assemblies) are the values are disassociated when opening the project in the new version of the IDE.
My suggestion is to not use ResX files unless you have to (to localize resources - not just text - and to manage strings in a single place) and just upgrade your project file, fix any problems, and be done with it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|