473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Assembly problem

Hi, I'm trying to add the product, title and version number to my main form
with the following code. I've tried using this code in the public class
FrmMain section but I get the error thisAsm' denotes a 'field' where a
'class' was expected. Also it will not compile 'this' with the error Keyword
this is not available in the current context
Any ideas?
Thanks

Assembly thisAsm = this.GetType().Assembly;
string messageHeader = ((AssemblyProductAttribute)thisAsm.GetCustomAttrib utes
(typeof(AssemblyProductAttribute), false)[0]).Product +
((AssemblyTitleAttribute)thisAsm.GetCustomAttribut es
(typeof(AssemblyTitleAttribute), false)[0]).Title + " V" +
Assembly.GetExecutingAssembly().GetName ().Version.Major.ToString() + "." +
Assembly.GetExecutingAssembly().GetName().Version. Minor.ToString();
Nov 16 '05 #1
1 1649
Tried moving the code to the public FrmMain() method but I then get the
compile error: The name 'memessageHeader' does not exist in the class or
namespace 'HRUtils.FrmMain'.

I also get the same error if I move the code to a test method like
public string test()
{
Assembly thisAsm = this.GetType().Assembly;
string messageHeader = ((AssemblyProductAttribute)thisAsm.GetCustomAttrib utes
(typeof(AssemblyProductAttribute), false)[0]).Product +
((AssemblyTitleAttribute)thisAsm.GetCustomAttribut es
(typeof(AssemblyTitleAttribute), false)[0]).Title + " V" +
Assembly.GetExecutingAssembly().GetName().Version. Major.ToString() + "." +
Assembly.GetExecutingAssembly().GetName().Version. Minor.ToString();
return messageHeader;
}

This is really very odd as all I want to do is have a string messageHeader
that I can call to show in the main form and also display in some message
boxes. Is it better to store the product name and version etc. in a resources
file or another class?



"Telmo Sampaio" wrote:
Hi Jez,

Try moving your code to a method (such as the constructor). Code should be
created inide a property or method, not in the main body of a class.

HTH,

Telmo Sampaio
MCT

"jez123456" <je*******@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi, I'm trying to add the product, title and version number to my main
form
with the following code. I've tried using this code in the public class
FrmMain section but I get the error thisAsm' denotes a 'field' where a
'class' was expected. Also it will not compile 'this' with the error
Keyword
this is not available in the current context
Any ideas?
Thanks

Assembly thisAsm = this.GetType().Assembly;
string messageHeader =
((AssemblyProductAttribute)thisAsm.GetCustomAttrib utes
(typeof(AssemblyProductAttribute), false)[0]).Product +
((AssemblyTitleAttribute)thisAsm.GetCustomAttribut es
(typeof(AssemblyTitleAttribute), false)[0]).Title + " V" +
Assembly.GetExecutingAssembly().GetName ().Version.Major.ToString() + "."
+
Assembly.GetExecutingAssembly().GetName().Version. Minor.ToString();


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Gomis | last post by:
I have encountered a situation where I am unable to remove a .NET assembly from the GAC. The message I receive is "Assembly 'assemblyname' could not be uninstalled because it is required by other...
5
by: Peter Gomis | last post by:
I have encountered a situation where I am unable to remove a .NET assembly from the GAC. The message I receive is "Assembly 'assemblyname' could not be uninstalled because it is required by other...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
1
by: Tim F | last post by:
Problem: I'm receiving the error "File or assembly name XXXXX or one of its dependencies, was not found." when trying to execute code in an assmebly that has both a strong-name and has been...
0
by: Andy | last post by:
Thanks Peter, I thought I'd give an update on this problem. My application had 2 assemblies that contained classed for the Data access and business logic layer. It was on one of them that I was...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.