Object datasources vanish from rdlc data sources in web project
Anyone having issues with their object datasources appearing and
vanishing from the datasource browser?
I create an object for binding as a datasource in my App_Code folder,
compile my web project and it appears in the datasources in the report
designer. Then I will make an aspx, setup a reportviewer control for
my new report, go back to the rdlc and the object datasource sometimes
just vanishes.
I refresh, no luck.
The only solution I found is to draft the rdlc to the App_Code folder
where my class is, then refresh datasources and it finds it. Then if I
move it away, they vanish again.
Am I missing something on how the object datasources work in web
projects?
Answers
- Both Reporting Services and Visual Studio are currently investigating this problem. At this point we don't have a better workaround to offer you. As soon as we have a fix or workaround available we will post it here.
All Replies
- Do you have at least one .aspx file open? Because of a bug in Web projects, Report Designer is only able to get a list of available objects if you have at least one .aspx file open. Open a .aspx file, then close and reopen Report Designer.
- Sometimes it seems to work sometimes it does not. Like i just was editing my RDLC, and suddenly it made another datasource in the Report->Data Sources, mydatasource1 in addition to mydatasource.
Why does that happen?
Also I will delete the mydatasource1, go back to my report, and bang the datasource window refreshes with no business objects in it (an aspx page is open).
No matter what I do, rebuild the project, open/close rdlc with aspx open, close VS and reopen everything, nothing works.
Any other workarounds? - This is still a problem, has anyone else encountered this?
I build my project, open an aspx like Rajeev said, open a fresh new RDLC, bang, website data sources show NONE of my business object datasources.
I close open .net a bunch, recompile, move files around and sometimes it refreshes with them there.
This is INSANE and destroying my productivity, can ANYONE else help??? I am encountering the same issue. I initially thought it was related to a Web Referrence in my Project and opened a Support Incident with Microsoft. Since that time, I have been having nothing but trouble with my object data sources. Most of the time (95% or more) the object data sources are simply not there. This is also creating major problems with my productivity.
The last I heard from Microsoft is that they are going to talk with the Reporting Services team (who built this component) and see if there is something they can do to fix the problem.
- I have been experiencing this issue since beta. Has anyone reported this bug?
I have reported the bug and it is under review with MS, please go vote 5 for importance and validate it and such, it is:
FDBK43122
at http://lab.msdn.microsoft.com/productfeedback/default.aspx
this is the direct link, not sure if it will work, but bugs with more votes get more attention, rather then dupe bug entries.
Well I'm glad I'm not going crazy. I too have been having this issue though I must have spent a few days thinking it was my business object code that was broken. Anyway I went and voted on the bug for whatever good that may do. Your link works fine.
I would lov eto hear if anyone finds a workaround. I have been pulling my hair out trying to find anything that might make this work the way it should...
- Both Reporting Services and Visual Studio are currently investigating this problem. At this point we don't have a better workaround to offer you. As soon as we have a fix or workaround available we will post it here.
- Any news with this problem? My team can't write any reports because VS keeps dropping data sources at random.
- Well I am using business objects exclusively in my report as the datasources. I have looked at the codebehind in the .rdlc using a text editor (it uses a nice readable xml format) and manually assigned the correct datasource when it gets stuck. Once you do that it seems fine from then on. Not sure if that will help or not...
- Thanks for the tip. Clarification: where and what are you changing manually? For instance, here's some XML from a test RDLC form:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="DummyDataSource">
<ConnectionProperties>
<ConnectString />
<DataProvider>SQL</DataProvider>
</ConnectionProperties>
<rd:DataSourceID>41dd4cb9-4901-4b16-8239-453f84dfe8d2</rd:DataSourceID>
</DataSource>
</DataSources>
<BottomMargin>1in</BottomMargin>
<RightMargin>1in</RightMargin>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ReportItems>
<List Name="list1">
<Left>0.125in</Left>
<ReportItems>
<Textbox Name="YearApproximate">
<Left>2.875in</Left>
<rd:DefaultName>YearApproximate</rd:DefaultName>
<ZIndex>2</ZIndex>
<Width>1in</Width>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Height>0.25in</Height>
<Value>=Fields!YearApproximate.Value</Value>
</Textbox>
<Textbox Name="Name">
<rd:DefaultName>Name</rd:DefaultName>
(etc.)
So, are you modifying stuff in the <DataSources></DataSources> block? - One thing that has also worked for us is, if opening an aspx file does not refresh the datasources list, try choosing Reset Window Layout from the window layout. This refresh the list for us but only after we'd also opened an aspx file.
- My WebSite Datasource is vanish too!
- We have found a general workaround for this problem.
This works for us because we use a data layer which is stored as a reference in our ASP.Net bin folder in our project:-- Right click on the bin folder and choose Add Reference
- Choose 'Browse' then browse to the bin folder of your site and choose an existing dll
- This will create a .refresh file underneath the selected dll
- Check your Website data sources, choose refresh (will likely still be empty or incorrect)
- Right click on the .refresh file and choose Delete
- (optionally) Close/open a .aspx file from the root of your web project. This often causes a refresh.
- Switch back to your report file, if not showing your data sources, choose refresh again - if still not showing try step 6 once more.
- If still not showing phone microsoft tech support and spend your life on hold (hopefully it's worked for you already though!)
- Contemplate early retirement.
Christopher Cook
Webprofusion Ltd Hi, I think I've got the solution. If I'm wrong forgive me, but its working for me now. If your second class below returns "As List(Of Class1)" then the Business Object will show in Data Sources when opening a report. If the structure of your class is exactly like below it will work.
Imports
Microsoft.VisualBasic
Imports System.Collections.Generic
Imports System
Imports System.Data.SqlClient
Public Class Class1
Private _symbol As String
Private _volume As Integer
Private _price As Double Sub New() End Sub Sub New(ByVal symbol As String, ByVal volume As Integer, ByVal price As Double)
_symbol = symbol
_volume = volume
_price = price
End Sub
Public Property Symbol() As String
Get
Return _symbol
End Get
Set(ByVal value As String)
_symbol = value
End Set
End Property
Public Property Price() As Double
Get
Return _price
End Get
Set(ByVal value As Double)
_price = value
End Set
End Property
Public Property Volume() As Integer
Get
Return _volume
End Get
Set(ByVal value As Integer)
_volume = value
End Set
End PropertyEnd
ClassPublic
Class Class2 Private m_products As List(Of Class1)
Public Sub merchant()
m_products = New List(Of Class1)
m_products.Add(New Class1("Pen1", 23, 22))
m_products.Add(New Class1("Pen2", 23, 22))
m_products.Add(New Class1("Pen3", 23, 22))
m_products.Add(New Class1("Pen4", 23, 22))
End Sub Public Function GetProducts() As List(Of Class1)
Return m_products
End FunctionEnd
Class- Has anyone found a work around this is getting very frustrating?
Hi, I've posted some code on how the Object DataSource should return a collection of a class. It only worked for a week or so and then the source was gone. The report though still worked.
I've found another approach that I think is worth trying out: I still create my Object DataSource and bind it to the ReportViewer. I then create a DataSet selecting only the fields that I want displayed on the ReportViewer. Use the Dataset in your 'Website Data Sources' to drag on you fields (designing the report).
The Business Object can now fetch the data and return it as a DataTable or DataReader or a collection of the Business Object. If you use 'collection of Business Object' make sure the properties has got the same names as the field names in your DataSet that you've used to design the report.
The DataSet will not vanish and you basically only use it to design your report with it. The data that get binded to the report are handled by you Business Object.
Hope this makes sense.
Milass your first post works as long as that class is part of my website but all of my BO's are part of a seperate assembly.
I do not want to work with datasets at all I only want to work with my business objects but I may give your second solution a try. All of my BO's are in a seperate assembly and it works about half of the time where I can drag and drop BO's to my report.
I have found if I create the report in the actual assembly that contains all of my BO's I can build object data sources and they seem to work fine, but I am stuck on loading them from the assembly or embedded resource at runtime (this is new to me)
THanks
Jerry:
Any progress on a workaround for this bug? Your post is from January. It is now July!
Lambert
Ok, I found out what causes the data source to vanish in my case. If I add a COM reference written by a company called ESRI, they vanish. If I delete the COM reference, they come back. What a hassle! I imagine that some of the other posts on this thread are a result of DLL conflicts as well.
Microsoft: This is a repeatable bug.
Lambert
- Thanks for the tip, I have had success using the text editor to re-add the correct data source. Another thing that I noticed was that the connection string used in the .rdlc is the connection string that is used in the server explorer, not the web.config connection strings. I am using MySql as my site data source and have created all of my datasets from that source. I just think that the connection string has to be fixed and should mirror the connection string used in the dataset table adapter. This could be part of the problem. I don't know.
- So now Microsoft has investigated this problem for more than 6 months, and there still is no solution to this problem? This is a very annoying bug which makes working with the report control totally frustrating. So Microsoft, are you listening at all, could you give us at least a workaround or indicatin that you actually are doing something? In the bug database, you have just closed this issue without any workaarounds or explanation. Easy way to take care of bug report: just close the issue and forget it ?!
- I'm posting this 10 months after the initial post - I have the same exact problem, and worse... every solution posted here has worked once for me, but not twice.
I have to move on from this technology, and recommend to my team that they not touch it. It might as well never have been built.
Sorry, and good luck. I've spent most of the day today with the same frustration, but have found the reason why this is happening.
The object data source shows up so long as I don't have the class defined with the DataSource or DataSourceAttribute attributes. I have a bunch of classes defined with this attribute that do not show up, but once I remove that attribute, there they were.
Obviously it's not ideal to remove that attribute if you want the classes to show up as data classes when adding a data source to an ObjectDataSource control, but all in all it's not a big deal. Too bad so much time is spent on these little things, though.
- Its almost 7 months later, I have some people at MS working this ticket for me. So far nada.
At present, I'm developing an intranet project along using the Beer House starter kit as a sort of template and, wanting to add reporting capabilities to it, have run into the same problems as the other posters, with the added wrinkle that when the website datasources actually do turn up, I can only see classes in my DAL, and nothing from the BLL. You can experience the same frustration by downloading the Beer House kit from the official ASP.NET website and trying to add a report to it. On one machine I get nothing, and on the other only a few classes from the DAL.
Does anyone know the current status of this? I find it hard to believe that such a long-standing and obvious bug still doesn't appear to have been rectified, especially as it renders the reporting control pretty much useless.
After many months we have found a workaround which may help. We noticed that the datasources window is often blank the first time you open a solution, but if you close and reopen the solution, it works. To clarify, if the datasources window is blank, select File\Close Solution, then File\Open\Solution without exiting VS.
Hope this helps. There may be more than one bug involved, so we are not sure it fixes all instances of the problem.
-Albert
End of March, and the ms guy who was helping me (sql server team) has given up. My ticket now points to a similar ticket, this one for the vs team. Which has always made sense - once you make a report, it continues to work, even if the objects have disappeared. Its pretty crappy; once when I went to Data/Show Sources, there was also an "Add Sources" option. I selected it, and there was a dialog whether you wanted to create a dataset, a web service, or a business object (if you create a windows form app, you always get this dialog). Thinking Id found nirvana I selected business object, and got a weird runtime error. Actually, come to think of it, I was able to duplicate it, take screen prints, and send them to vs. The guy who was helping me from the sql server was amped, said we could squich it, and a week later hasta la vista. I had the same idea as the other guy posted, use a dataset as sort of an intermediary. When I looked into the hassle to do so I decided it wasnt worth it.
I wonder if anyone from ms is bothering to look at this.

I posted a workaround at the bottom of this thread. Does that help you?
-Albert
Thanks, Albert- unfortunately that doesn't work for me.
The main problem I'm having is not so much that no datasources are shown, but that only a subset of them appear. The problems I was having can also be replicated by downloading the Beer House sample application from the official ASP.NET site and creating a report in the project. Only classes in the DAL are shown, no classes from the BLL appear. There doesn't seem to be any rhyme or reason to it. I can get by by hand-editing the report's XML, but it's a bit of a chore to be honest, especially if there are several fields.
I cannot get any website data sources to show up for the Report.
Has anyone gotten a good response from Microsoft. There seems to be scarce information about this out there.
Yes it did, for awhile. I noticed that behavior fairly early on this, and I could have lived with it. Doesnt make a difference now.
I just used refractor on the source of vs.net 2005 and saw this:
public static AllowReportToWork(Microsoft.Framework.System.Reports rid)
{
if (rId=Microsoft.Framework.System.Reports.VisualStudioReports.BusinessObject)
{
int foo= ReturnDecreasingLackOfProbability();
(bool)System.Randomize(foo);
return foo;
}
else
return true;
}
Sorry for the cynicsm. On second thought, Im not. I just had to tell some users that reporting for the new app will have to be re-architecture. Appears I bet on the wrong horse.
Any solution??
Why MS feedback is closed? Is it corrected? Any fix?
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=114670
Tku
Richard
I believe that I have a workaround that will consistantly refresh the website datasources window. I moved the rdlc file that I was working on to the app_code folder at the base of my project. I have opened it and worked with it several times without any problems. I also noticed that if the data sources disappear when I am working on one of the rdlc files that is not in my app code folder and the data sources disappear that I can open the one that is in the app code folder, the data sources appear for that one and from that point on the data sources appear for all rdlc files.
I belive you can either move all of the rdlc files to the app_code folder or simply place a dummy rdlc in the app_code folder and when the problem occurs, open the dummy one to get the datasources refreshed. I hope this helps everyone....
- I having the same problem - I've tried everything suggested here but nothing has added my custom object to the website data sources list. I went and voted on the bug. I doubt it matters - this looks like MS has abandon the control.
I had this problem.
Took a while, but it seems Visual Studio 2005 Service Pack 1 caused the problem for me.
I removed it, the objects were back. I installed it again, objects gone.
Hope this helps someone or more info comes from this.
This posting saved my day - yes, I added a dummy .rdlc file to the app_code folder, saw all website datasources showing up, then opened my .rdlc files in a folder outside the app_code, and problem gone.
Thanks PBallance! There can be many other getarounds, but this one is most economic.
- A combination of two proposed solutions has apparently worked for us. The first solution proposed was that an ASPX file must be open. With a lot of experimentation I've found that default.aspx must be open first (not any aspx, it must be default.aspx). Second, opening any RDLC from the App_Code folder will load all of the custom objects. These 2 steps together has worked 100% of the time for us. Using the steps individually would work sometime and not others. Sometimes we would get system objects, but not our custom objects. Sometime we would get only SQL Data Sets. However, opening the 2 files I mentioned together allows us to open other RDLC files and have all objects available every time. Closing default.aspx will sometimes cause the objects to vanish, but opening it again causes them to re-appear. Hope this is helpful...
Well,
One and a half year after the thread has started the problem still persists. And as the new version of Visual Studio is almost ready to ship, it has surely been left aside.
Nevertheless, I would like only to comment that the solution that tells we should keep default.aspx opened and the .rdlc file in the \app_code directory works for me. So, that is the work around I adopted.
Regards.
It is now June 2007, Microsoft considers this issue resolved and closed:
They don't offer any advice on how to use this tool, but I'll bet they're demonstrating it at trade shows.
This is typical of Microsoft, make something for a group demo but it won't work for *** when you try to do actual work.
A QFE is in the works to fix this issue. Normally, QFE's are issued fairly quickly, but this one has taken so long I don't want to make any predictions. Thanks for your patience.
-Albert
- Hotfix KB939768
I've business objects in a 'class library' which is a seperate project in my web application.
Some business objects show there, some do not.
The important ones do not.
I couldn't find any Hotfix KB939768.
You need to request the Hotfix from Microsoft Customer Support. Use this link: https://support.microsoft.com/contactus2/emailcontact.aspx?scid=sw;en;1410&WS=hotfix and request article number 939768.
-Albert
You can add another voice to the collective screams for help. Microsoft please stop putting out technology and saying it works our Pinhead Bosses and Pinhead Clients believe you and then we get skewered when things do not work. Please stop. Considering early retirement.
On the First Day Microsft made the Dataset.
On Second Day (it was a half day) Microsoft made the Object.
The Object never did live up to Microsofts expectations.
I installed the Patch but I am still unable to browse the objects I need. I will have to succumb to using a DataSet definition to create the report.You guys deleted the comment by that mad britton, I guess you can censor it's your site.
Anyway for those who are interested as I stated in my previous comment even after the patch I was unable to see my object data sources in the Web Site Data Sources window. I finally broke down and in a completely separate project Created a dataset source upon doing this my object data sources in the app_code folder appeared and were usable in the Web Site Data Sources. So there another slimy feeling work around.
I got the hotfix by requesting it from the link above. It didn't work, I still don't have any website data sources.
Just fyi.
FYI
I was able to have the Object Data Sources showby creating a dataset source from a stored procedure. Once the sproc Datasource was on any object data sources in my app_code directory also appeared.
I just want to confirm that the two work arounds do indeed work --- most of the time. At least often enough to not be annoying. I'd like to also add that while trying to get those two fixes to work I discovered that if you right click the app_code folder and do a view class diagram it will generate a new class diagram if not there already. Then for some automagical reason the web datasources will appear. Go figure. I even had a few more show up that I didn't see before with the other two fixes. Anyway, I thought I would help relieve the collective headache by sharing.
Has any body found a fix for this? I tried all the work arounds in previous post and the MS hot fix at http://support.microsoft.com/kb/939768 but did not work.
- If anyone is still following this thread, I have not too good news: Exactly the same behavior is happening in VS2008!!!!!!!! The same workaround of inserting a dummy report on app_code half-works (sometimes yes, sometimes not). Which means... they say they improved the Reports tool, but they didn't fix something basic for a real life user!
Half day lost in assuming corrections were done on the tool... - I'm getting the wierd datasource behavior as well in Visual Studio 2008. The datasource objects appear (most of the time), but you cannot refresh the properties if they have changed in the underlying object.. Argh!! This has been an ongoing issue for quite some time (VS 2005 - VS 2008) and seems like it should be so easy to fix. Microsoft, get your head out of the sand.... please!!!!!!!!!
n/a - Dummy.rdlc in app_Code works for me, too. Once I created a dummy.rdlc in tha app_code folder, all the data sources appeared miraculously, even for the .rdld reports outside the app_code folder.
Thank you all for posting here, you helped me find a solution in an hour, can't immagine what you were going through.
- I have this issue with Visual Studio 2008, all SPs installed. If I start a new project , create a report, I can add data source, in my current project, the new data source button is disabled, was there ever a fix?
- I too had no datasources displaying in datasources window.
I tried several things from this thread- all to no avail.
I re-opened Visual Studio and all the datasources displayed fine. - Hi,
Here it's a simple issue! What u have to do is open a rdlc report in desion view
then u can see "Data " in the menu.
Then click Data----> Show Data Sources (Shift+Alt+D).
bye!!!!
- It's now the end of 2009 and this issue still persists! Come on MSFT!
In the meantime, I have a workaround that may work for some developers out there. I'm currently working on a multi-layered web site project using .net 2.0. My solution contains the web site project plus several class library projects that form my Business Layer (BL) and Data Access Layer (DAL). My BL defines business objects (not datasets) that I want to use as datasources for my .rdlc report. My DAL queries the database and passes generic lists of business objects back to the code-behind files in my UI. I then programatically pass these lists to the report using:
Dim myList as List(Of MyBO) = MyDao.GetBusinessObjects()
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("MyBO", myList));
As everyone else has noted, business objects have a hard time showing up in the Website DataSources window. Granted, having the datasources show up there makes it much much easier to design the report by dragging and dropping fields onto the .rdlc design template, but it is NOT a requirement. You can still build the report without your objects displaying in the Website DataSources window, but the workaround can be relatively labor intensive. The goal is that the .rdlc needs to have some knowledge of what data to expect so you can design the layout by placing textboxes and other report elements. Ideally, you would do this by dragging and dropping fields from the Website DataSources window, but you can also add datasources to your .rdlc manually by directly editing the underlying XML of the report. To see what I mean, right-click the .rdlc in Solution Explorer and select "Open With..." then choose "XML Editor." That opens the .rdlc in its native XML format.
To add your business object as a datasource, look for a section named <DataSets>. If your report's XML doesn't have this section, add it. Here's the XML for a simple business object datasource with an ID property, FirstName property and LastName property:
<DataSets>
<DataSet Name="MyBO">
<Fields>
<Field Name="ID">
<DataField>ID</DataField>
<DataType>System.Int64</DataType>
</Field>
<Field Name="FirstName">
<DataField>FirstName</DataField>
<DataType>System.String</DataType>
</Field>
<Field Name="LastName">
<DataField>LastName</DataField>
<DataType>System.String</DataType>
</Field>
</Fields>
</DataSet>
</DataSets>
This will add a class named "MyBO" as a datasource for the report. The FieldName is the name of the field in report element expressions. If you were to add an expression to a textbox on the .rdlc, you could now write something like:
=Fields!ID.Value
to display the ID in the textbox. The <DataField> corresponds to the name of the public property in the MyBO business object. Once the datasource has been added to the XML, you'll see the class and its properties appear in the report's Expression Editor.
The pain is having to manually add the XML representation of all the business objects you plan to use in the report. I'm sure you could create a tool to process each business object and spit out an XML file, then copy those contents into the .rdlc. That's what I plan to do.
I know this is not an ideal solution, but it works. I hope this helps someone out there. Good luck!
Sr Software Eng


