|
Something else is wrong, then. So long as you have something like this:
[assembly: AssemblyVersion("1.0.1.1")] You'll never have an incremental version number (and it's technically not incremental - see the attribute documentation in the .NET SDK). Also make sure that if you use the AssemblyFileVersionAttribute that you fix that as well, although I don't think that accepts an asterisk.
Make sure that you have project references as well instead of assembly references (when you add a reference, click the Project tab instead of selecting an assembly) and make sure that you have one and only one AssemblyVersionAttribute defined at the assembly level (prefixed with assembly: ). You shouldn't have any problems. If you do, you have something wrong.
And, no, I can't share that system. It's our flagship product.
If you want the versioning system I use, it's almost the same as what the C# compiler uses. The major and minor versions (the first two) you set. The third is the number of days since January 1, 2000, and the last is incremented to signify minor changes. We don't change that number much except for minor bug fixes since Fusion requires that a new assembly version exists or it won't download it (we use touchless-deployment over the 'net). The build is typically the number of days from 1/1/2000 till the target release date so that we don't change it ever day.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey Guys,
If I have created an App.config file in my project, and in that file specified a key and a value. Then coded the following :
string test1 = System.Configuration.ConfigurationSettings.AppSettings["Key1"];
tabPage1.Text = test1;
This sets the Text Property at the top of the Tab Page on start up to what i specified in the config file. Now i want to change the BackColor property of the Tab Page, but i constantly get the following error: Cannot implicitly convert type 'string' to 'System.Drawing.Color' ? Any assistance appreciated.
|
|
|
|
|
You must use the ColorConverter to covert the string to a color, like so:
Color c = this.BackColor;
string color = ConfigurationSettings.AppSettings["BackColor"];
if (color != null)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
try
{
c = (Color)converter.ConvertFromString(color);
}
catch { }
} You can also use the AppSettingsReader , but this is limited to reading types with a Parse method:
AppSettingsReader reader = new AppSettingsReader();
bool b = (bool)reader.GetValue("ShowInTaskbar", typeof(bool)); The first way I outlined is far more extensible and provides support for more types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks. What if I were to want to set the Alignment property of the TabControl itself ? I've gotten continuous errors with this as well.
|
|
|
|
|
Again, a TypeConverter . Use TypeDescriptor.GetConverter(typeof(TabAlignment)) to get an EnumConverter . You might want to read-up on the TypeConverter in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Cool, i'll read up on the type converter, since im guessing if i want to set any properties that are not strings, this is what i will be doing. Thanks for your help.
|
|
|
|
|
Word of warning - not every type has an associated TypeConverter . Only those types that are attributed with or inherit the ConverterAttribute with a valid TypeConverter (or simulate this through the component model) work. Enums, primatives, and many structs support TypeCoverter s. If you need something more encompassing, then forget about using the <appSettings> section and use a serialization approach, like using XML Serialization (see the System.Xml.Serialization namespace in the .NET Framework sDK). There are many articles here on CodeProject that discuss such an alternative. You could even create your own .config section and use XML Serialization to deserialize more complex types that may or may not have a TypeConverter associated with them. Just search this site for examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can you group sections in a config file, such as
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
<add key="LabelText" value="Test text">
|
|
|
|
|
Sorry, forgot to click the Do not treat <'s as HTML tags
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
|
|
|
|
|
Ok, dont I dont get that one I think you know what I mean. Can i group keys via a tag such as "label" for all keys refering to attributes of a label ?
|
|
|
|
|
Ok, dont I dont get that one I think you know what I mean. Can i group keys via a tag such as "label" for all keys refering to attributes of a label ? Because it keeps giving me a problem with it.
|
|
|
|
|
You might want to encode your < and > with < and > next time.
You can group sections, but they must be accessed as part of a group. You really need to read about .config file. See the IConfigurationSectionHandler for good information and a start. Once you decide to group a section you cannot move it around.
For example, the system.web section is a group and there are many section handlers configured under it (configured in the machine.config file). They are all accessed as "system.web\sectionName". If you change the group they are in, you break the code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to display selected items in a listview on another form. for example, I have a form with a listview, three textboxes (lastName, firstName, idNumber), and three buttons (Add, Save, View Form). When I click the view form I want the selected row of items to be displayed on another form that has three textboxes. I have tried many different techniques but none work. Does anyone know how to do this? Any help would be appreciated especially a coded example!!!!
|
|
|
|
|
If these are in the same AppDomain (by default, every process includes one AppDomain), you only need a reference to those TextBox es. It's really a simple object-oriented problem.
So, for one example, when you create your Form with the ListView , pass a reference to the Form with the three TextBox es. Make those TextBox es public or internal (internal is public within an assembly). In the ListView.SelectedIndexChanged , get the ListViewItem and set the TextBox.Text property in the other form using the reference you have to it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear forum members,
An object of a managed class (written in C#) is passed to the
clipboard during drag&drop operation. The object has to be
dropped on to a MFC view (written in VC++ .Net).
How do I create/access my object from the COleDataObject
which I get while 'Droping' into a view ?
Is there any other way to do this ?
Thanks in advance.
svkr.
|
|
|
|
|
I already answered your previous post[^]. Like it or not, those are your only two options: exposing a CCW and publishing the interface, or marshaling the data.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've been using this code without any problems for ages
FolderBrowserDialog Dialog = new FolderBrowserDialog();
Dialog.RootFolder=Environment.SpecialFolder.Personal;
Dialog.ShowDialog();
This stopped working this afternoon just before a demo of my app; There is just a grey window with the create new folder button and OK. Copied into a new app with a button the code works as i would expect.
The only thing i think might have caused it was that i applied a manifest to get the XP look and feel just before i compiled. I can't get the old style browser back now though, i've deleetd the exe and recompiled etc.
this is the manifest i used with the AppName changed to Appname
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity
version="1.0.0.0"
="" processorarchitecture="X86" name="Microsoft.Winweb.AppName" type="win32">
<description>.NET control deployment tool
<dependency>
<dependentassembly>
<assemblyidentity
type="win32"
="" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorarchitecture="X86" publickeytoken="6595b64144ccf1df" language="*">
anyone has any ideas, i'd be very happy to hear some answers
Russell
|
|
|
|
|
I once experienced the same thing. After long experiments I discovered that this error occurs when the COM threading model for an application is multithreaded apartment (MTA) instead of single-threaded.
<br />
[System.STAThread]<br />
static void Main()<br />
{ <br />
System.Windows.Forms.Application.Run(new MainForm());<br />
}<br />
Maybe you changed that too?
www.troschuetz.de
|
|
|
|
|
Stefan,
You are a complete and utter hero. I did indeed change the threading model of the application, i had never even thought that that could have caused the problem, i'd got myself convinced that it was something to do with that manifest.
Thanks, at least now i know why it's broke i can test some threories
Russ
PS. i just checked the code, and it was just the [System.STAThread] that was missing, excellent fix, thanks
|
|
|
|
|
My pleasure
arachnoid wrote:
i had never even thought that that could have caused the problem
I know what you mean. I only discovered this solution by accident.
arachnoid wrote:
now i know why it's broke i can test some threories
Maybe you can find out why the COM threading model affects the FolderBrowserDialog this way. I never figured that out
www.troschuetz.de
|
|
|
|
|
i'm going to be coding a prog over the weekend that makes extensive use of threads, so hopefully i'll understand more about them soon. I've only ever used threads in Java and VB(Don't go there, it hurt bad), so i'm just trying to get to grips with syntax etc at the moment.
I don't see why the folderbrowser should be sensitive to the threading model when the commondialog isn't, they do pretty much the same thing after all.
I've just found some code on MS site that shows how to use the clipboard from within an MTA thread by spawning an STA thread within your apartment, maybe that'll work for the folderbrowser.
Russ
|
|
|
|
|
Hi guys, here's my problem.
I have a C# console application and a C# windows forms application running on Windows 2000. The console app runs in a full-screen console, the windows app in a normal window.
Most of the time I will be in full screen mode. But sometimes, my console app will need the help of my windows app, so it makes a remote call to the windows app.
The windows app maximizes iself and takes the focus (user needs to see some information). This causes the console to minimize, and I can see windows desktop, taskbars, all that. After the windows app is done, I want the console app to take the focus back and into fullscreen mode again.
But I can't seem to get that last step to work. Best I've been able to do is make the console window blink on the taskbar. I used DllImport attribute to import user32.dll, and used the WinAPI function SetForegroundWindow to do that.
I basically want to emulate the Alt-Tab functionality. So, since Alt-Tab works there must be a proper way for me to get it to work too. I just don't know what that is. What's the proper way to do this?
|
|
|
|
|
Why is the console app full-screen? This is atypical of a console application. You might consider redesigning your application as a Windows Forms application that can prompt for it's own data. If the console application contains important code you don't want to port, consider using a shared assembly that both the console and Windows Forms application use.
As far as simulating Alt+Tab, you can use SendKeys like so:
SendKeys.Send("%{TAB}"); If you want to do this programmatically, P/Invoke SystemParametersInfo and change the SPI_SETFOREGROUNDLOCKTIMEOUT to 0. See the Platform SDK documentation for the SetForegroundWindow for more information and the reason why.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for your prompt reply!
The console application is full screen because it is being exec'd by a legacy application that must run in a full-screen console window. (This legacy system will be replaced by something being written in .NET from scratch in a year or 2, but until then I'm stuck with this as an interim solution).
I am able to switch tasks with no problems if the windows are not full-screen mode windows. I am only having problems if the console window is in full-screen mode.
I don't really want to simulate Alt-Tab. I only mentioned it because Alt-Tab has no problems switching to a full-screen window, so I know there is a way I can do it too. I just want the console application to give itself focus and maximize itself back to full-screen after the windows application has done its thing.
I will go ahead and read up on that documentation, and see if it solves my problem.
|
|
|
|
|
Is it possible to create an assembly with both C# files and MC++ files?
I have MC++ code that I need it to be private but the code uses it is in C#.
I am open to other suggestions. (ie making the MC++ assembly such that it can only be used by a specific assembly)
Thanks!
Orhun Birsoy
|
|
|
|