473,772 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Explicit Conversion from Object to Reflection.Asse mblyCompanyAttr ibute?

Help a newbie out. I cannot seem to explicitly convert an Object to a
Reflection.Asse mblyCompanyAttr ibute type using DirectCast(). Turning Option
Strict "Off" is not an option.

Here is the Error:

Option Strict On disallows implicit conversions from 'System.Object' to
'System.Reflect ion.AssemblyCom panyAttribute'.

Here is the code:

Public ReadOnly Property Company() As String Implements
IAssemblyInfo.C ompany
Get
Dim attrCompany As SR.AssemblyComp anyAttribute
'*** The following line produces the conversion error ***
attrCompany =
Me._assemblyInf o.GetCustomAttr ibutes(GetType( SR.AssemblyComp anyAttribute),
False)(0)
Return attrCompany.Com pany.ToString

End Get
End Property

Any help is greatly appreciated.

carl
Nov 21 '05 #1
2 1413
Carl,
Try the following:

attrCompany = DirectCast( _
Me._assemblyInf o.GetCustomAttr ibutes( _
GetType(SR.Asse mblyCompanyAttr ibute), False)(0), _
SR.AssemblyComp anyAttribute)

Hope this helps
jay

"Carl Fenley" <clfenley-X-@-X-wcpci.com> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
| Help a newbie out. I cannot seem to explicitly convert an Object to a
| Reflection.Asse mblyCompanyAttr ibute type using DirectCast(). Turning
Option
| Strict "Off" is not an option.
|
| Here is the Error:
|
| Option Strict On disallows implicit conversions from 'System.Object' to
| 'System.Reflect ion.AssemblyCom panyAttribute'.
|
| Here is the code:
|
| Public ReadOnly Property Company() As String Implements
| IAssemblyInfo.C ompany
| Get
| Dim attrCompany As SR.AssemblyComp anyAttribute
| '*** The following line produces the conversion error ***
| attrCompany =
| Me._assemblyInf o.GetCustomAttr ibutes(GetType( SR.AssemblyComp anyAttribute),
| False)(0)
| Return attrCompany.Com pany.ToString
|
| End Get
| End Property
|
| Any help is greatly appreciated.
|
| carl
|
|
Nov 21 '05 #2
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
Carl,
Try the following:

attrCompany = DirectCast( _
Me._assemblyInf o.GetCustomAttr ibutes( _
GetType(SR.Asse mblyCompanyAttr ibute), False)(0), _
SR.AssemblyComp anyAttribute)

Hope this helps
jay


Thanks! That worked like a charm.

carl
Nov 21 '05 #3

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

Similar topics

1
5655
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases at the bottom. Hope you can help me understand the "explicit" keyword and its usage. Specifically, Is "explicit" keyword only associated with constructor in C++? What's "implied conversion of types"?
9
2373
by: Tanmoy Bhattacharya | last post by:
Hi, This is a question about whether I am right that a particular syntactic sugar is missing in C++. Let me explain with an example. Let us say I have a class for complex numbers, and I want people to be able to initialize real numbers (like an object of type double) from it ... in such a context (or if someone explicitly casts to double), the imaginary part is to be ignored. However, I certainly do not want people to be able to ask...
3
2111
by: spamadress | last post by:
Hello I wonder why only constructors can be qualified with explicit to prevent implicit conversion, but not conversion operators. To me the following makes perfectly sense: struct A { explicit operator int() { return 0;} ; }; void foo(int) {};
2
6870
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public static explicit System.IntPtr (long);
31
3616
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1(); Control c = f; An enum value inherits from int but it doesn't get implicitly converted: HorizontalAlignment h = HorizontalAlignment.Center;
11
12797
by: Aaron Queenan | last post by:
Given the classes: class Class { public static implicit operator int(Class c) { return 0; } } class Holder
9
1549
by: D.J. Stachniak | last post by:
Hi, I have a question about explicit constructors and the C++ standard. Forgive me for my laziness in not pouring over the spec myself, but I thought I'd ask first and read later. I have a class/app like so: #include <string> #include <iostream> class UTF8string
14
4065
by: Noone | last post by:
Hello all, Ok, I want to create a program that will load plugins (dll's) from a plugin folder. I can create the forms and put them into a dll but I cannot actually add them dynamically at run time. I have tried to use the LoadLibrary and GetProc functions, which sort of worked. I got the pointer to the function but I cannot actually RUN the function like I can in C++. I have heard some things about Invoking(?) I believe but I cannot...
42
2704
by: coder_lol | last post by:
Thanks everyone again for contributing to helping me clear C++ confusions. I did some serious reading on copy constructors and assignments and I think I've got a good handle on the memory stuff. Well, I came across Scott Meyer's SmartPtr example from some 10 years ago. I like the template member function for type conversion to solve inheritance issues. On MSVS 2003, I get the below error, if I declare the constructor SmartPtr(T*...
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.