473,545 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = ((AssemblyProdu ctAttribute)thi sAsm.GetCustomA ttributes
(typeof(Assembl yProductAttribu te), false)[0]).Product +
((AssemblyTitle Attribute)thisA sm.GetCustomAtt ributes
(typeof(Assembl yTitleAttribute ), false)[0]).Title + " V" +
Assembly.GetExe cutingAssembly( ).GetName ().Version.Majo r.ToString() + "." +
Assembly.GetExe cutingAssembly( ).GetName().Ver sion.Minor.ToSt ring();
Nov 16 '05 #1
1 1662
Tried moving the code to the public FrmMain() method but I then get the
compile error: The name 'memessageHeade r' does not exist in the class or
namespace 'HRUtils.FrmMai n'.

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 = ((AssemblyProdu ctAttribute)thi sAsm.GetCustomA ttributes
(typeof(Assembl yProductAttribu te), false)[0]).Product +
((AssemblyTitle Attribute)thisA sm.GetCustomAtt ributes
(typeof(Assembl yTitleAttribute ), false)[0]).Title + " V" +
Assembly.GetExe cutingAssembly( ).GetName().Ver sion.Major.ToSt ring() + "." +
Assembly.GetExe cutingAssembly( ).GetName().Ver sion.Minor.ToSt ring();
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*******@disc ussions.microso ft.com> wrote in message
news:65******** *************** ***********@mic rosoft.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 =
((AssemblyProdu ctAttribute)thi sAsm.GetCustomA ttributes
(typeof(Assembl yProductAttribu te), false)[0]).Product +
((AssemblyTitle Attribute)thisA sm.GetCustomAtt ributes
(typeof(Assembl yTitleAttribute ), false)[0]).Title + " V" +
Assembly.GetExe cutingAssembly( ).GetName ().Version.Majo r.ToString() + "."
+
Assembly.GetExe cutingAssembly( ).GetName().Ver sion.Minor.ToSt ring();


Nov 16 '05 #2

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

Similar topics

2
20627
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 applications." Although I have seen this before when trying to remove .NET assemblies that have been installed via an MSI package, I now get this...
5
374
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 applications." Although I have seen this before when trying to remove .NET assemblies that have been installed via an MSI package, I now get this...
3
4387
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 really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing...
1
2351
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 installed into the GAC. We originally had this assembly without a strong-name and we were successfully using it by referencing it when it was NOT in the...
0
3932
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 getting the Access denied error. After checking different settings and googling I wasnt able to pinpoint the problem and as a temporary fix I...
0
7685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7784
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6014
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5071
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3485
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.