Class (Business Object) not appearing in Report Data toolbox for RDLC - rdlc

I have created a local report in a class library (as embedded resource) and I want to use the existing business objects as the data source for the report. When I try to add the business object from the Report Data toolbox I cannot see the class that I want to choose. What I've noticed is that if the business object is a subclass of another class which exists in a another class library then it doesn't appear. Has anybody else seen this? So what I've tried is this:
Scenario 1:
Class Library 1
Reports folder > Report1.rdlc
BO folder > MyBO and MySuperClass
public class MyBO : MySuperClass
When I open up Report1.rdlc and try to create a New Object Data Source from the Report Data toolbox, MyBO class is visible and I can select it. If I change my solution to this:
Class Library 2
namespace ClassLibrary2 { public class MySuperClass { ... } }
Class Library 1
Reports folder > Report1.rdlc
BO folder > MyBO
public class MyBO : ClassLibrary2.MySuperClass
Now when I try to add the MyBO class it does not appear in the Report Data toolbox. Unfortunately I'm using a product and my Business objects have to be subclasses of the super class that is in the other class library.
Does anyone know how to fix this issue or is this a bug? Oh, I'm using .Net 4 and VS2010. Thanks.
Kind regards
Sidharth

I found the same issue today and tracked it to the fact that when the project is compiled as 64-bit in Debug mode that the Data Source Wizard does not find anything. If you switch to x86, they magically appear. I guess the Wizard is 32-bit.
My current work around is to set Debug mode to x86 and Release to x64. In this way, I can edit datasources as need be. The final Release doesn't have any problem running.
However, I did not see it dependent on being a sub-class. Maybe your other libraries have Debug set to x86 and hence the wizard works.

Related

Namespace and base class not recognized - Why?

So I am working on a project someone gave me.
In the project, there is a main Namespace, lets call it "Program".
In that namespace are several different classes.
Now I had to derive from a class in Namespace Devices.
There was already another class derived from the object Device.
So I went ahead, created my class, included it in the Devices namespace, derived it from Device and did my job.
But not shortly afterwards, I couldnt use any of the base variables, methods and so on. The whole intellisense doesnt work on that class.
And even worse is, that it doesnt seem to be included into the assembly.
How can I get my class being recognized by Intellisense, the assembly and so on? I made a test class which only was like this:
Namespace Devices
Class Testcle
' ... Nothing
End Class
End Namespace
And it worked perfectly fine. It was included in the assembly, Intellisense worked, etc.
The folder structure looked a bit like this:
[Project]
↳ [-] Devices (Folder and Namespace)
[-] AlreadyExistingClassDerivedFromDevice (Folder)
↳ AlreadyExistingClassDerivedFromDevice.vb
[-] MyClassDerivedFromDevice (Folder)
↳ MyClassDerivedFromDevice.vb
↳ [+] Other (Folder)
↳ Testcle.vb
↳ Device.vb
Is there anything Im missing? Like is there a hidden setting I have to activate?
Edit:
The declarations look a bit like this (but in different files):
Device.vb
Namespace Devices
Public MustInherit Class Device
' ...
End Class
End Namespace
This works:
AlreadyExistingClassDerivedFromDevice.vb
Namespace Devices
Public NotInheritable Class AlreadyExistingClassDerivedFromDevice
Inherits Device
' ...
End Class
End Namespace
This doesnt work:
MyClassDerivedFromDevice.vb
Namespace Devices
Public NotInheritable Class MyClassDerivedFromDevice
Inherits Device
' ...
End Class
End Namespace
There is literally no difference with the inheriting classes. Only the inner workings. But those shouldnt have an effect on the accessability of the ctor or Intellisense or something, right?
I write this as an answer because it solved my problem. However, I dont know what cause it had and dont know the exact steps to actually solve the problem in a 'proper' way.
What I did is the following:
I renamed the file MyClassDerivedFromDevice.vb to MyClassDerivedFromDevice_Old.vb, created a new class named MyClassDerivedFromDevice.vb and just after adding the namespace and making sure Intellisense and everything works properly, I just copied the code from MyClassDerivedFromDevice_Old.vb (after the line Namespace Devices up to End Namespace into MyClassDerivedFromDevice.vb.
That solved the problem.
Short version:
1) Rename NotWorkingClass.vb to NotWorkingClass_Old.vb
2) Add new class with name NotWorkingClass.vb.
3) Add Namespaces to NotWorkingClass.vb.
4) Check whether everything works accordingly (Intellisense, etc.) and it is recognized by Visual Studio.
5) Copy all code starting after Namespace X to right before End Namespace from NotWorkingClass_Old.vb to NotWorkingClass.vb (which should now work).

Show Base Class throws error if base class is generic and in a class library

Say I have a class library project (Library) which contains a class of:
Public Class SomeClass(Of TTypeA, TTypeB)
Then, in another project UIProject in a different solution, I define a class that is derived from (inherits) SomeClass:
Imports Library
Public Class SomeDerivedClass
Inherits SomeClass(Of String, Boolean)
I have included Library.pdb and Library.xml alongside Library.dll (in the same folder) when I added the class libary reference to the UIProject.
Now, In UIProject I create a ClassDiagram (ClassDiagram1.cd), and add in the SomeClass class. So far so good.
The next step is to right-click on SomeClass in the diagram, and select "Show Base Class" from the dropdown. At this point, I am given the error:
Error HRESULT E_FAIL has been returned from a call to a COM
component.
If I do the same but for a non-generic version of SomeClass, then SomeClass is included in the class diagram, no problem.
No errors show up in ActivityLog.xml; nor in the Windows Event Viewer.
Is this a bug in Visual Studio (in which case I'll report it); or am I doing something wrong (and if so are there any other error logs or traces I can do to narrow down the issue further)?
The answer seems to be that COM does not work with generic types; and that it works in VS2017.

Why can't i reference to a method/property? VB.NET

Please take a look at the 2 photos i attached, i wish to call the methods from one project to another. Both projects are in the same solution. I have already made the reference to the project containing the method in the project i want to call the method.
http://postimg.org/image/m42dlc28r/
http://postimg.org/image/w03gkz80r/
In your main project, go to
Project -> Add Reference
In that window, click browse and find the compiled version of your other project (Probably in the Release or Debug folder)
In your main projects window add this to the very top of your code (even above your class declaration)
Imports SecondProjectRootNamespace
That should give you enough information on how to do what your trying to do, but if anything was unclear, I am going to need all the details to provide a more precise answer.
Also, make sure your methods/functions are NOT declared as private.
Private = Method is only visible from within the same class
Friend = Method is only visible from any class within the same assembly (same .exe or .dll or etc)
Public = Method has no access restrictions
There are a few others but those are the basics
Try to find the dll file of the method that you want, then add it as reference in the properties of your application

Project to project reference - type not CLS compliant

I have a problem regarding a public declaration in one project which makes reference to a class in a different project.
The parent project references the dependent project without problem. However, I'm getting a warning that Type member 'user' is not CLS-compliant. It's declared as
Public user As User
this declaration is made in the parent project. User is a class in the supporting project
I can use the type on a form without fail. Now, I try to pass it off on another form - in the parent project:
Private oldUser As User
oldUser = frmUserMgt.user
and the thing crashes. Stepping through the code shows oldUser is nothing.
I built a brand new solution and tested this exchange without fail. I've searched solution and project settings until I'm blue in the face and can't find a difference. It's a VS2012 VB solution. I can post as much code as needed if the above description isn't sufficient - any help will be greatly appreciated.

Why Can't I Inherit IO.Directory?

Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable!
I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function.
Please advise and I will send you a six pack. OK nevermind I'm not sending you anything but if you come to the bar tonight I will hook you up and then beat you in pool.
From the Meta Data of .NET
namespace System.IO
{
// Summary:
// Exposes static methods for creating, moving, and enumerating through directories
// and subdirectories. This class cannot be inherited.
[ComVisible(true)]
public static class Directory
You cannot inherit from a Static Class.
Are you using C# 3.0 VB.NET 2008 -- then you could add an Extension Method
If you use the DirectoryInfo class, you will have access to a MoveTo function.
EDIT: I'll correct myself... The static Directory class already has a Move method.
I'd guess that Reflector isn't picking up the sealed attribute correctly for VB (or perhaps just not displaying it properly). If you look at the IL, it is sealed:
class public abstract auto ansi sealed beforefieldinit Directory