473,326 Members | 2,173 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,326 software developers and data experts.

problem with reflection

Hi all,

I'm using reflection and want to know how this piece of code can be
realized with reflection.

Code:
(SomeInterface) myObject = (SomeInterface)SomeObject

With kind regards,

Marco
Nov 15 '05 #1
2 1069
If you meen with CodeDom, that this would be the code:

Notes:
the left-hand-value of an assign-expression don't have to be casted ->
myObject = (SomeInterface)SomeObject.

CodeAssignStatement s = new CodeAssignStatement(
new CodeVariableReferenceExpression("myObject"), //i asume that
'myObject' is a variable
new CodeCastExpression(
typeof(SomeInterface),
new CodeVariableReferenceExpression("SomeObject") //SomeObject
also a variable?
)
);

hope it helps,

Günter Prossliner
"Marco V" <ma******@dolfijn.nl> wrote in message
news:21*************************@posting.google.co m...
| Hi all,
|
| I'm using reflection and want to know how this piece of code can be
| realized with reflection.
|
| Code:
| (SomeInterface) myObject = (SomeInterface)SomeObject
|
| With kind regards,
|
| Marco

Nov 15 '05 #2
Marco,
I'm using reflection and want to know how this piece of code can be
realized with reflection.


If you want to check if you can cast an object to a certain interface,
use Type.IsAssignableFrom(). The actual cast can't be done with
reflection.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #3

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

Similar topics

4
by: Nicolas | last post by:
The lat part is not working why ???????? Please help......... using System; namespace ConsoleApplication4 {
3
by: dan | last post by:
Hi all, I have a reflection-problem I'm totally stuck with. Maybe someone has a hint... I want to get a fieldinformation of an event from the Control class, e.g. "TextChanged". FieldInfo fi =...
1
by: Raveendra M | last post by:
Hi! I am working with ASP.NET application. In my page I am creating one Application Domain and in that domain I am calling my DLL. Using the methods of the dll. And unloading the Application...
0
by: David Berman | last post by:
Hello, I'm receiving an error reading the machine.config file when I try to access my web application. This error came out of nowhere. After searching many sites, googelizing and searching here,...
6
by: Ken Varn | last post by:
I have an ASP.NET application that is calling a custom class that is trying to parse all of the members of my Page object using Type.GetMembers(). The problem that I am having is that private...
1
by: Dominique Vandensteen | last post by:
I want to dynamicly load a type (typename is defined in the database). This type is located in the exe itself or one of the dll's in the directory with the exe file. When creating an instance...
2
by: Marco | last post by:
Hi, I try to use reflection to retrieve class B members and not inherited members. I wonder why the myMember value is nothing. Any suggestions? Thanks Module Module1 Sub Main()
2
by: Andrea V.F. | last post by:
I use the code below (VB.NET) to display a Popup balloon in the Tray Icon of my application. The balloon is displayed, but the timeout never happens and the balloon is always visible even if I...
15
by: satankidneypie | last post by:
Hi, I'm going to start this off with some code as it'll make it easier to explain afterwards... using System; namespace ConsoleApplication1 { /// <summary>
2
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.