Base class '<baseclassname1>' specified for class '<partialclassname>' cannot be different - vb.net

"Base class <baseclassname1> specified for class
'' cannot be different from the base class
'' of one of its other partial types"
The problem is that I only declared the class in one place, the actual class file, and only declared it once, non partially.
All my other classes that inherit from "DialogBase" work fine, but one file with the most code just stopped working.
What else could be the problem? Could it be declared partial somewhere else?
Class CostDialog inherits DialogBase(This works fine)
Class Blend inherits DialogBase(This errors)
Blend is only written as Public Class Blend in the Blend.vb file ONCE
This error makes no sense

You may have multiple code behind files with the same class name. I was converting a web site to a web application and found that there were two instances of Home. So Project/abc/home.aspx /aspx.vb and Project/def/home.aspx/ /aspx.vb will cause a conflict if both home.aspx.vb files have the same class name.
My fix was to leave all the file names untouched but modify the class name to abc_home and def_home in their respective code behind file and then change the Inherits property at the top of their .aspx pages.
Highly doubt this is still an issue for you, but maybe for someone else.

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.

Should there be a link between the class name and the file name in which it resides?

OK, so I have 2 files (header and implementation) named MyLib.h and MyLib.m, inside those 2 files I have multiple classes, protocols and interfaces but none called 'MyLib'. Now, everything works just fine, I have only one problem, xCode doesn't show me any class hint except for MyLib (which btw is only the name of the file, there is no MyLib class).
Now, this small problem made me think about it, is this a bad practice? Is is better to have a file for each class and if yes, why?
I just created a .h file with a different name from the class inside it, and Xcode gives me the completion for the class name, not the file name. Have you #imported the header wherever you're trying to use it?

Xwiki Create virtual wiki - problem adding a class

I'm trying to create a virtual wiki but I already struggle with
In your Class Editor, create a new class called "XWikiServerClass"
Further reading in the DevGuide / DataModel shows that I'm not alone. I understand the words saying but I don't get the how-to as there is no option in the class-editior of creating new classes. Navigating to class editor shows an info box
No class is defined in this wiki document. You can create one by adding properties from the panel on your right, or you can choose another class to edit from the list below.
Ok, I added 'XWikiServerClass' and would have expected to be able to add a type class but that's not possible. I've tried a few properties but nothing shows up as a class in class editor.
Can you give more info on how you set up your wiki ?
As far as I know, you should have installed xwiki-enterprise-manager-web-x.y.war and modify your setup to fit your needs.
Second, you should have imported "xwiki-enterprise-manager-wiki-administrator-x.y.xar into your empty instance.
This xar archive already contains the XWikiServerClass and a very handy set of pages to automate the creation of virtual wikis.

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