How to manually set the GUID for a VB6 Activex control - vb6

Recently we have an issue where we have to modify an ActiveX control which is developed long back. Problem is, we lost the source code, but we found another version of the same control with a different GUID.
The requirement is to keep the old GUID as other products are using the same control. So we want to replace the new control GUID with old one.
Is it possible? If so please let me know how can I change the GUID of the Active X control in VB6.

You don't manually put the interface & class GUIDs into your application, but in your project settings you need to enable "Binary Compatibility" pointing to a DLL that has the interface & class GUIDs that you want to have your project use.
From the Visual Basic 6.0 Project Documentation Component Tools Guide, "Providing a Reference Point for Binary Version Compatibility":
To specify a reference version of the component type library
Open the project.
From the Project menu, choose Project Properties to open the Project Properties dialog box, and select the Component tab.
Click Binary Compatibility to lock down the class IDs in the project.
Note As explained in "Project Compatibility: Avoiding MISSING References," the Project Compatibility setting actually has nothing to do with the Version Compatibility feature.
Update the box at the bottom of the Version Compatibility frame with the full path and name of the most recent version of your component.
Whenever you make a new executable from your component project, Visual Basic compares the new interfaces of your classes to the ones described in the file you have specified. Visual Basic updates the type library version number according to the level of compatibility between the interfaces.
For more information, be sure to read through all the sections in the "Version Compatibility in ActiveX Components" portion of the documentation.

Related

"Reference manager" missing in custom project type (in VS IsolatedShell)

I'm working on a VS IsolatedShell 2015 application; my current goal is to enable project references.
However when right-clicking the 'references' node in a project there are basically no options available, most notably for my case the reference manager is missing:
The project itself is based on CPS, so maybe I need to enable this somewhere in there?
The project does contain these capabilities (as documented here):
<ProjectCapability Include="AssemblyReferences;COMReferences;ProjectReferences;SDKReferences" />
I've also added the ReferenceManagerProjects & DependenciesTree capabilities (another link) and made sure that there are rule files for the resolved references (I tested this by manually adding some assembly references to the project and those are displayed correctly).
Within the Shell .pkgundef file the 'web specific packages' are enabled, as hinted in the last answer on this page.
I've also looked through all other pkgdef/pkgundef files, but nothing else looked like it should be responsible for the reference manager.
Are there any other places that could lock the reference manager out?
Or is there some interface that has to be implemented for CPS to enable this?
Turned out one solution to the problem was adding an implementation of the IProjectCapabilitiesProvider and return the capabilites for the reference types I needed there:
public Task<IEnumerable<string>> GetCapabilitiesAsync()
{
return Task.FromResult<IEnumerable<string>>(new[]
{
CustomProjUnconfiguredProject.UniqueCapability,
"AssemblyReferences",
"ProjectReferences"
});
}
The reference manager can still not be accessed using the 'references' node, however using the context menu on a project you can find it in 'Add' > 'Reference'

What's purpose of <Use64BitIISExpress /> element in csproj file

When I edit Web application project, Visual Studio 2017 (15.3.1) adds <Use64BitIISExpress /> element under Project/PropertyGroup in csproj file.
I can't find any documentation, what is the purpose and if it affects something, when presented (as it is, without any attributes).
Only result I was able to find was mention about registry value of the same name.
Does someone know what this element serves for?
Was it introduced in some of recent updates of Visual Studio 2017?
I noticed this entry, not surprisingly, after I made a change to the Properties page of the my Project. Under the Web section of the Properties page, you'll see a section called "Servers". After I changed the "Project URL" to use the correct port number for debugging, this entry appeared (not because I changed that option specifically, but it's when I noticed it appearing).
<Use64BitIISExpress />
In this section you can select either "IIS Express" or "External Host". Next to that dropdownlist, there is another dropdownlist for "Bitness". Mine was currently set to "Default", which displays the entry in the Project file as an empty element. After changing the "Bitness" to "x64", my Project file entry changed to:
<Use64BitIISExpress>true</Use64BitIISExpress>
Changing my "Bitness" to "x86" results in:
<Use64BitIISExpress>false</Use64BitIISExpress>
Returning "Bitness" to "Default" makes it again an empty element:
<Use64BitIISExpress>
</Use64BitIISExpress>
I understand this doesn't address your question of "where is the documentation?". I, too, could not find any relevant MSBuild documentation for this attribute. But, I thought it worth noting where the attribute is coming from and how it acts based on selected options from the Project properties while we anxiously await some formal, official documentation.
The purpose of that (pretty obvious) is to start IIS Express in 64bit mode. It is the equivalent of setting 64bit only on the Application pool in IIS.
If your project has a dependency on a DLL that only runs under 64bit mode then this is when you need to set it. This has been available since VS2013
Probably is useful if you prefer to do do F5 debugging instead of
process reattaching for your pure 64bit applications
This started showing up in the config files since VS2017 due to all the changes happening with Visual Studio portability. (VSCode, Visual Studio Mac, Xamarin, etc)

ActiveX Control Versioning VB 6.0

I have OCX created using VB 6.0. And this OCX has custom activex controls in it. The custom controls are used in my application. I have installed my application in a system in which I have registered mu first application.
My second application needs the custom controls which are available in my OCX , few enhancements in previous controls and new custom controls.
For this purpose I have created new OCX with previous controls and new control added. In this case in future if I need different controls I need to create more OCX files. This is difficult to maintain different OCX.
If I add new functionalities in the existing OCX and register in the system, already existing application couldn't able to find the previous version of activex control.
How to add new features in already existing ocx with out affecting the applications already using these controls?
Thanks
Publishing a component with "Binary Compatibility" allows this (with several caveats involving what you can safely change) by examining the existing version of the activex control and then re-using IDs from the type library in the new version at compile time.
See here for an explanation: http://wynport.wynsys.net/Visual_Basic_Binary_Compatibility.htm which includes a list of what incremental changes you can make.
When you compile your project, Visual Basic only creates new Class and Interface IDs when necessary. It preserves the class and interface IDs from the previous version(s) so that programs compiled using an earlier version will continue to work. If you are making a change that will result in an incompatible version, Visual Basic will warn you. If you want to maintain compatibility with older, released versions of an ActiveX component.
Ref: http://support.microsoft.com/kb/161137
To make your control binary compatible,
Open the properties dialog of project
Select Component tab
Select Binary Compatibility radio button
Browse your existing control which you have compiled
Click OK button and recompile your project

VBP file tags value

I have open VBP file in notepad and there are differet tags over there like CompatibleMode, Command32, HelpContextID, ServerSupportFiles, CompilationType, OptimizationType, FavorPentiumPro(tm), CodeViewDebugInfo, StartMode.
I wanted to know the meaning of this different tags. Please revert if you have any idea. I found on google but didnt found anything.
All these tags are referring to your project properties.
When opening your project in VB6 goto the "Project" menu and click on "projectname Properties...". From there on the VB6 help can tell you everything you want to know.
For example
Version Compatibility
Allows you to set the level of version compatibility
No Compatibility — Compatibility not enforced.
Project Compatibility — If checked, the Location box is active and
allows you to search for the file with which this project is to be
compatible. If cleared, the Location box is not available. For all
ActiveX project types, Project Compatibility is checked by default.
Binary Compatibility — Useful for maintaining compatibility among
projects that have been compiled using your component.

Visual Studio 2010 property sheet inheritance

I am trying to move my c++ project setting into property sheets. I use multiple third party libraries, but they are not used by all of the projects.
Is there any way to use property sheets to bring in settings specific to the third party library I need for each project (mainly include and library directories). I would like to be able to do this at a project level rather than a global level so if I get a new library I can test it without breaking my normal development projects.
As an example:
Library1: needs include directory X:\Lib1\Include and lib directory X:\Lib1\Lib
Library2: needs include directory Y:\Lib2\Include and lib directory Y:\Lib2\Lib
I tried creating two property sheets, but it appears that as VS moves through the hierarchy, it just uses the newest version of the settings that it finds (according to that hierarchy).
Is there any way to configure these so the directories properties are cumulative?
Thanks,
Eric
Click the drop-down arrow on the right of the field, select 'Edit' Check the box "Inherit from parent or project defaults' and this will automatically add the neccessary macro (eg $(AdditionalIncludeDirectories), etc)

Resources