|
Hi everyone. This is my first post
Firstly I would like to say that this seems like a very valuable site for the inexperienced like myself. I am literally in my first week of development and comprehension of C#. So I think a few newbie questions must be expected.
My problem is this. I have never used the commandline. For the project I am working on now, I must make an assembly. But the only way that the .NET documentation says you can do this is through the commandline. This is terrible Could someone please help me in just pointing out where I can do this in the IDE
Thanks
Skylo
|
|
|
|
|
Skylo wrote:
But the only way that the .NET documentation says you can do this is through the commandline.
If you've got your solution in the IDE already then to compile it all you need to do is select Build-->Build Solution or press Ctrl+Shift+B
To run the assembly (assuming it is an exe) you can press F5 or use the menu Debug-->Start.
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)
|
|
|
|
|
Hi Colin. Thank you very much for the reply. I know about de-bugging and what not but what I would like to do is create an assembly. I have three projects in a solution.
Now I understand that an assembly is almost like a casing that one may put a class in, in order that one may use the class throughout the other projects. This is what I am confused about: ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpguide/html/cpconbuildingsingle-fileassembly.htm.
That seems like the only documentation I can find on assemblies?
I hope that helps you understand my dilemma
|
|
|
|
|
Hi,
You're link didn't work for me - I must have a different version of MSDN installed. Can you tell me the title of the document so I can look it up - or provide the equivalent link to the online version of MSDN? Thanks.
If you can debug your solution then you already have the assemblies. An assembly is just a .NET DLL or EXE file. When you Build your solution the assemblies are places in the bin/Debug or bin/Release directories within your individual project directories.
To use assemblies in different projects within a solution you must add a reference to the assembly you want to use in the project that you want to access it. To do this right click the References node in the solution explorer and select "Add Reference". Click the "Projects" tab and select the project that contains generates the assembly you want to use. In individual .cs files you should add a using statement at the top with the namespace of the code in the assembly you are using.
Some good practice is that an assembly should only contain one namespace, or one branch of a namespace structure.
I'm kind of hitting out in the dark here. Let me know if anything seems to be going in the right direction.
"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)
|
|
|
|
|
Thanks Colin. All is good. Your explanation has helped me. The title that I was refering to was "Building Assemblies". Confusing this Microsoft thing. In Java everything is laid at our feet!
...one of the main causes of the fall of the Roman Empire was that,
lacking zero,
they had no way to indicate successful termination of their C programs.
-Robert Firth-
|
|
|
|
|
The .NET Framework SDK itself is not tied to Visual Studio .NET (VS.NET). VS.NET is merely a helpful IDE that helps with development tasks, but everything it does when building assemblies you can do from the command-line, such as using the C# command-line compiler (csc.exe), the license generator (licgen.exe) and the resource generator (resgen.exe). Utilities that are similar in use to when VS.NET creates Web Service proxies or COM interop assemblies are wsdl.exe and soapsuds.exe, and for interop tlbimp.exe and aximp.exe. If you were to register your CCW (COM-Callable Wrapper, a .NET class exposed as a COM class) you can use regasm.exe and optionally tlbexp.exe to generate a typelib for your classes in that assembly.
"Building Assemblies" merely discusses this from the SDK standpoint, which comes with all these programs (actually, some come with the Framework itself like the command-line compilers). Anyone can download the SDK and build without VS.NET. I find myself doing it a lot when I need a quick test or example code to use here on this forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Wow. Thank you very much Heath. You guys have been very helpful. I think I have found a "home". Now doing a conversion of a .csv to a .xml then through to a datagrid.
Will be asking a few questions, I am sure of that.
Keep well and happy programming to all
Skylo
...one of the main causes of the fall of the Roman Empire was that,
lacking zero,
they had no way to indicate successful termination of their C programs.
-Robert Firth-
|
|
|
|
|
Skylo wrote:
Will be asking a few questions, I am sure of that.
No problem, but let give my usual drivel about checking the docs first. It's obvious from your previous post that you did read through a particular topic already, so - congrats - you're on your way (much more than many people, believe me). Self-discovery always teaches you more than being told.
See the System.Xml namespace for help. Creating XML documents (and reading and modifying them, of course) is very easy with .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've tried to set the background on my component to transparent, but i get an error saying that the component does not support transparent backgrounds. Is there a way around this?
Cata
|
|
|
|
|
Transparency is not controlled at the control level, but rather at the form level. You can see this easily if you create a sample project WindowsForm project, add some conrtrols, and view the properties of the controls, then the form. So unless you are doing a DropDown control in PropertyGrid, you would handle your transparency at the form level. If you are doing PropertyGrid dropdowns, you cannot be transparent since IServiceProvider is only fed a control instead of a form.
To handle transparency, your code would be something like:
System.Windows.Forms.Form newForm = new Form();
MyNamespace.MyControl digit = new MyControl();
newForm.Controls.Add(digit);
newForm.Opacity = 60;
newForm.Show();
_____________________________________________
Of all the senses I could possibly lose, It is the one called 'common' that gets lost the most.
|
|
|
|
|
Hi,
Thanks for the reply, but that's not what i'm looking for. When i try and use a color containing alpha channels as any type of background color on a component, it throws an exception.
i.e.
this.BackColor = Color.FromArgb(0,this.BackColor);
This is a custom component, not one that is pre built into .net, and i know that these ones do support alpha channels, so i'm a bit confused as to how to implement it in mine.
Cheers
Cata
|
|
|
|
|
Hi!
I need help, my problem is that i need to know when the scrollbar in a RichTextBox reaches the bottom. I know that vScrollbar and hScrollbar has a value that you can set or get but how to do this in a RichTextBox?
Thanks!
Johan
|
|
|
|
|
You can either P/Invoke SendMessage and use the SBM_ messages to sent to the handle for the RTF control (see RichTextBox.Handle , inheritted from Control ), or P/Invoke the recommended scroll functions like GetScrollPos :
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.SysInt)]
private static extern int GetScrollPos(IntPtr hWnd,
[MarshalAs(UnmanagedType.SysInt)] int nBar);
private const int SB_HORZ = 0;
private const int SB_VERT = 1;
private const int SB_CTL = 2; To note, GetScrollPos is provided for backwards compatibility for older code and the Platform SDK docs recommend that you use GetScrollInfo instead, which also requires that you declare a struct for use with the P/Invoke method.
Using the method above, you can get the scroll position for the range (the page in this case) using something like this:
int pos = GetScrollPos(myRTFControl.Handle, SB_VERT); If you need to know what the range is, you can use the GetScrollRange . In this case, though, you could actually get both the position and range back at the same time if you did use GetScrollInfo . This is enough information to get you going, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the answer!
I will try it!
/Johan
|
|
|
|
|
I cant get it to work...
mabye i do it wrong??
I have tryied the GetScrollPos as in the code above but i get a error when i run the program that is:
marshal return value: Invalid managed/unmanaged type combination (Int32/Uint32 must be paried with I4 or U4)
And i dont know how to work this one out...
Please help...
Thanks
Johan
|
|
|
|
|
Oops, typo! Change UnmanagedType.SysInt to UnmanagedType.U4 as the exception message suggests.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a Xml document like this and i want to show the databases of session "Development" in a datagrid. But i don't know how.
If i do it like this:
ds.ReadXml(@"c:\xmlfile.xml");
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "database";
He will take the databases of both sessions, i just want the databases of the first OR the second session.
Thx in advance.
<?xml version="1.0" standalone="yes"?>
<sessions version="1.0">
<session name="Development">
<databases>
<database name="ffw100">
<physicalname>fastforward</physicalname>
<databaseorder>1</databaseorder>
</database>
</databases>
</session>
<session name="AppserverDevelopment">
<databases>
<database name="ffw100">
<physicalname>fastforward\ffw100</physicalname>
<databaseorder>1</databaseorder>
</database>
</databases>
</session>
</sessions>
|
|
|
|
|
That's not a valid format for a DataSet , so you won't be able to bind to the elements you want. DataSet s have either 2 or 3 levels. In the case of 1 level below the root (which is required by XML) a generic table name is used, IIRC, like "Table1", but you can always just use dataSet1.Tables[0] . In the case of 2 levels below the root each parent element is the table name and each child (leaf) element is a field. Each instance of the parent elements counts as a row, like so:
<DataSet>
<Table1>
<ID />
<Name />
</Table1>
<Table1>
<ID />
<Name />
</Table1>
<Table2>
<Stuff />
</Table2>
</DataSet> So this DataSet would have to two tables named "Table1" and "Table2". Table1 would have two rows and Table2 would have one. There's really not any other ways you can represent such a simple structure.
My suggestion is to extract the <databases< element(s) and put those into a separate DataSet (see the XmlDataDocument for some help with that) and bind against that.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
As Heath mentioned, your XML file is too complex for the dataset to properly parse. However, once you do have a dataset representation, binding to a specific session can be done by using a DataView of the table and setting the Row filter.
For example, I modified your source XML as follows, so that it can be parsed by the dataset.
<br />
<?xml version="1.0" standalone="yes"?><br />
<databases><br />
<br />
<!-- Development Sessions --><br />
<br />
<database><br />
<name>ffw100"</name><br />
<session>Development</session><br />
<physicalname>fastforward</physicalname><br />
<databaseorder>1</databaseorder><br />
</database><br />
<br />
<!-- AppDevelopment Sessions --><br />
<br />
<database><br />
<name>ffw100</name><br />
<session>AppDevelopment</session><br />
<physicalname>fastforward\ffw100</physicalname><br />
<databaseorder>1</databaseorder><br />
</database> <br />
</databases> <br />
Once you have the dataset, you can use a dataview to filter it before biding to the grid. The following code will bind the grid to only those databases used in the "Development" session. It will also sort by the "DatabaseOrder" node.
<br />
DataSet ds = new DataSet();<br />
ds.ReadXml(@"c:\test.xml");<br />
<br />
DataView dv = ds.Tables[0].DefaultView;<br />
dv.RowFilter = "SESSION='Development'";<br />
dv.Sort = "DATABASEORDER ASC";<br />
<br />
dataGrid1.DataSource = dv;<br />
dataGrid1.DataMember = "NAME";<br />
dataGrid1.DataBind();<br />
Hope that helps.
--Jesse
|
|
|
|
|
thx for your answer but i'm not allowed to change the Xml-file
I'm going to try now to get 1 session out the xml and save to a new file then use that to work with and when it's done bring it back to the original Xml-file.
Possible? Hope so
|
|
|
|
|
Can you Please give me an example of
client - server communication in .NET
using Remoting and configuration files.
I had problem with example given in several books.
|
|
|
|
|
There are a lot of tutorials right here on CodeProject.
Chek this section:
http://www.codeproject.com/csharp/#Remoting
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
When doing Remoting Configuration on client side
Can I have multiple entries under <client> like:
<client>
<wellknown type...>
<wellknown type...>
</client>
in the configuration file.
If yes, then how can I choose a particular entry and
get a proxy remote object.
|
|
|
|
|
If I understand your question, I think what you are trying to do is connect to one of multiple remote servers. If so...here is your solution which works for me today.
First, get rid of your client config.
Next you want to establish your channel and load your remote objects dynamically with code as well as having the ability to reset your location to go to a new server.
The reset is basically : at the time a new server is requested you close your connection and free up your channel.
Getting the channel is very generic. I use SOAP over HTTP is my connection returns the 'Version number error' and I use Binary over HTTP otherwise for speed and agility.
When the user has selected a location (in this code it is stored in a string variable named (obviously) url:
public static void reSetWebsite(NamedWebsite passedWeb)
{
currentWeb = passedWeb.Clone();
globalObjects = null;
if (channel != null)
ChannelServices.UnregisterChannel(channel);
}
public static void InitializeRemoting(bool DebugState)
{
try
{
if (DebugState == false)
{
channel = new HttpChannel(null,
new BinaryClientFormatterSinkProvider(),
new BinaryServerFormatterSinkProvider());
System.Diagnostics.Debug.WriteLine("MyApp has not been requested to run in debug mode.", "Remote Communication Manager");
}
else
{
channel = new HttpChannel(null,null,null);
runningInDebugMode = true;
System.Diagnostics.Debug.WriteLine("MYApp has been requested to run in debug mode.", "Remote Communication Manager");
}
channel.Properties["proxyName"] = null;
channel.Properties["useDefaultCredentials"] = "true";
ChannelServices.RegisterChannel(channel);
}
catch (System.Exception exc)
{
throw new System.Exception("Problem initializing the remote object channel", exc);
}
}
public static void LoadGlobalManager()
{
try
{
string location = url + "\GlobalManager.rem";
globalObjects = (IGlobalManager) Activator.GetObject(
typeof(IGlobalManager),
location);
System.Diagnostics.Debug.WriteLineIf(runningInDebugMode, "Placing remote communication library in debug mode", "Remote Communication Manager");
globalObjects.SetDebug = runningInDebugMode;
}
catch (Exception se)
{
throw new ApplicationException("Load of global objects failed", se);
}
}
_____________________________________________
Of all the senses I could possibly lose, It is the one called 'common' that gets lost the most.
|
|
|
|
|
When ever I put a node into the treeview I get
horizontal scrollbar immediately.
Ho do I avoid It?
How can I customize the TreeView Scroll Bar like backcolor etc.
|
|
|
|