Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reflection Question
Message
From
02/03/2010 15:18:13
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01452083
Message ID:
01452104
Views:
45
>>>I'm trying to instantiate a Crystal Report class using reflection:
>>>
>>>
>>>private void _SetupReport()
>>>{
>>>    int ReportId = Convert.ToInt32(Session.Contents["ReportId"].ToString());
>>>
>>>    string Command = "SELECT ReportName FROM ApexReports WHERE RecordId = " + ReportId.ToString();
>>>    DataSet dsReportName = DataLayer.ExecuteQuery(Command);
>>>
>>>    string ReportClassName = dsReportName.Tables[0].Rows[0]["ReportName"].ToString();
>>>
>>>    Report = (ReportDocument)Assembly.GetExecutingAssembly().CreateInstance(ReportClassName);
>>>
>>>    CRViewer.ReportSource = Report;
>>>}
>>>
>>>
>>>Report is null when this runs. The vaariable ReportClassName contains the correct name. What am I doing wrong?
>>
>>Assembly.CreateInstance() will only create a type contained within itself. Are you sure that this is the right assembly?
>
>I think so. It's an ASP.Net app and there are only 3 pages and the report. I thought I read somewhere that I needed to include
>the namespace, but I don't see any namespaces in a web app.

Kevin,

When you create a web with File| New Website it does not add the namespaces in the classes but they are assumed. If you create a web Application project with File | New Solution or Project and you pick Web Application Project you will get namespaces. I do not create any that are not based on project files in part for this reason and many others such as getting all the randomly generated dll files for all the pages. The WAP will create a single dll of the name you specify.

As far as namespaces in your file based web you will need to figure that out. I cannot say I remember how that works as it has been a long time. If you have any of the parts in folders those will add to the namespace.
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform