Why is my ObjectContext empty when debugging vb 6 dll for an asp classic page IIS6? - dll

I'm trying to debug a VB 6 dll that is used in an ASP classic page. I've gotten other dll working, but one in particular is causing me some real headaches. This one references the COMSVCSLib COM and when debugging, is empty.
...
Dim objContext as COMSVCLib.ObjectContext
Set objContext = GetObjectContext
...
When compiled and called from the asp page, all is fine,
<%
dim obj
set obj = Server.CreateObject("page_builder.glue")
obj.Login
set obj = nothing
%>
I have 'EVERYONE' added to all aspects of the VB ASP debugging DCOM.
I am running Windows Server 2003 in 32-bit on a 64 bit machine, using IIS 6.
As I mentioned other DLLs debug fine, it's just this aspect of this one that doesn't work.
Any suggestions?

The COMSVCLib.ObjectContext object represents the object context in the DCOM host (dllhost.exe). This context gives you access to properties that describe the configuration of your DCOM Application in Component Services.
When you run your .DLL project in debug mode in VB6 however, the DLL will be hosted by the VB6.exe process. This process doesn't have any configuration of the kind that your DCOM Application has, so the VB6.exe process doesn't contain any object context information.
Therefore the GetObjectContext will return nothing.

Related

Unable to read data from the transport connection VB6 calling com visible c# library

I have a c# Framework 4.7.2 Com visible library that calls a web api.
Unit tests in the VS2017 C# IDE library work fine.
However if I try to call via VB6 I get
System.IO.IOException unable to read data from the transport connection: An existing connection was forcibly closed by the rempte
host.
System.Net.Sockets.SocketException
I am running Windows 10
I call as administrator
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm /codebase /verbose /tlb:SBD.ComBridge.tlb C:\dev\SBD.ComBridge.dll
to create the .dll and .tlb
I also tried running regasm from the VS2017 command prompt as administrator
RegAsm reports that the libraries register successfully.
In Vb6 the (simplified) code is
Dim o As SBD_ComBridge.BridgeImplementation
Set o = New dBridgeImplementation
o.SetOrderDates id
set o = nothing
In BridgeImplementation the (simplified) code is
[DispId(25)]
[ComVisible(true)]
public void SetOrderDates(int Id)
{
PackAndSend.SetReadByInfo(Id) // calls freight service
}
I know that the code calling the service from within SetReadyByInfo works because my unit test passes when I run it in VS2017
Unfortunately I have been asked not to post the code. However I know that the vb6 code calls Com correctly because there are other methods I call without errors.
I had a similar issue with MYOB api and TLS the solution was to upgrade the Framework. However I can't upgrade the VB6 framework ( the large re-write is not an option) Probably I will just make a .Exe and shell out to it.
[Update]
The link Simon Mourier gave me solves it.
If I add
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
then my com call works on VB6
As the link points out,
This isn't a good solution since it hard codes what TLS version to
use, so it wouldn't use TLS 1.3 in future
As per the update section at the bottom of my question, a work around is to include
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I need to investigate further for a more complete solution

How To Reference a Com Object in a WCF Service

I need to reference a Com DLL from within a Silverlight program. Since this is not allowed, I created a wcf service and put my reference to the Com in it.
This idea seems to work fine when I ran my wcf service from my local machine but when I publish the service to my server it failed to work. The error was “Object reference not set to an instance of an object” where I tried to instance the DLL.
Here problem line is
m_cloVB6Encryption = New VB6Encryption.cEncryption
VB6Encryption is a complicated one. It called another DLL which calls several others.
To try to isolate the problem I created a very simple VB6 component, this time I got the error
"Retrieving the COM class factory for component with CLSID {74FE605A-5861-41A0-BA13-27DDD9C2EBB8} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
This is despite the fact that I manually registered the component and it was successful.
The problem line was cloSimple = New Simple.cSimple.
My computer runs Windows 7; the server runs Windows Server 2012 R2 Standard.
Presumably your COM component was build as 32bit...so when you register it is registered as a (InProc) 32bit COM component....(and can only be loaded by a 32bit application).
Your ASP.NET Website is most likely running in an AppPool that is set to be 64bit...thus it can't use the 32bit COM class.
There are 2 options (the clearest and easiest is option 1):
1) Get your IIS WebSite/Application to run as 32bit, so it can access your already registered 32bit COM component.
To make sure your website is running as 32bit too (instead of as 64bit)...change the DefaultAppPool to enable 32bit applications (or you can create a new AppPool which is 32bit specifically for that webservice/site and make it use it...if you don't want to affect other sites).
https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
OR
2) Do some additional registration so that your COM class is available to 64bit clients too (you register it so it is run OUT OF PROCESS...so it can be consumed by either 32bit or 64bit clients....but you might not want that for perf reasons...and it might not always be possible)
http://www.gfi.com/blog/32bit-object-64bit-environment/

Registering DCOM proxy on client machine

I have a .net 2 COM+ class library. It is installed on my machine running as the host server.
The COM+ object builds and registers, and I am able to call if via VB (open Excel and using dev mode added the reference, and then can call the object without any problems).
Now attempting to deploy to our test machine. Tried the following:
Export the COM+ object as Application Proxy
Export the COM+ object as Application Proxy with "Save application in COM+ 1.0 format."
After taking the msi and cab files to the client machine, ran the MSI. There were no errors on installation.
The object does show up in the registry (searched for it by GUID). The object does NOT however show up in the DCOM Config tree (also checked the COM+ tree as well just to make sure it is not there).
Looking at the win32 file in registry for the object, it shows it pointing to c:\Program Files\COMPlus Applications\ {GUID} \class.tlb This is valid as that is where the tlb is sitting, and the GUIDs match as well.
Does anyone know how to get this to work correctly?
Additional information:
The COM+ object is built via ClassInterfaceType.AutoDual as AutoDispose and None I could not get to work correctly.

Error 404 - file not found on Silverlight RIA service call

I have search everywhere for a solution to my problem, but I am not able to find one. I have built a Silverlight 4 Navigation app, and am using RIA Services to process a custom entity (which is essentially running server-side calls to COM dlls). In my debug environment, everything works fine, but when I try to deploy to IIS7 (on the development machine) as a website, it gives me the following error when calling the Get query on the entity:
Load operation failed for query 'GetNewHWCoil'. The remote server returned an error: NotFound.
at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error)
at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.<Load>b__17(Object )
Everything I found online says to check the Authentication area on IIS and make sure that it is set only to Anonymous Authentication, which it is. And they also say to enable WCF logging, which when I add the necessary text to the web.config file, I still don't get any logs. They also say to use Fiddler2 to trace the HTTP calls, but I only get a 404 error on there with the textview giving me the standard IIS file not found website. I cannot figure out how to debug this problem.
The Silverlight app needs to make calls to a set of 3rd party COM dlls to calculate the performace of water coils. Since I do not want to have the app run OOB, (this will negate the whole point of it being a web app instead of a WPF app) I have the ASP.net project interacting with the dlls using the custom entities.
The function (or Query as RIA services calls it) GetNewHWCoil is located in the DomainService class and uses this code:
Public Function GetNewHWCoil() as HWCoil 'HWCoil is a custom object
If bRanCalc then 'bRanCalc is a global boolean variable that gets set to true if the calc call on the dlls have been made
Return mHWCoil 'global copy of the calculated coil object
bRanCalc = False
else
Return New HWCoil
end if
End Function
The error runs before any calculation should be called, so it is assumed that it is erroring on the 'Return New HWCoil' part.
Any help on this would be appreciated.
Thanks,
Chris
I found the solution to my problem. I fonud out that I can have VS run the debug from IIS, and when I had it create the virtual directory it told me I needed to install ASP.NET 4 on the server. I thought that by checking the ASP.NET checkbox in the Add Windows Features dialog that I had already done that. But it only installed .NET 2 version. So after looking online for this new problem, I found that I needed to run the command
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -i
and everything worked fine after that.
Chris

Unable to debug web service project in Visual Studio 2008

I've been assigned a web app written in VB using VStudio.net 2003. I am trying to configure the source on my localhost (VStudio 2008) so I can explore and learn about the current app (before I begin any real changes) and I cannot get debugging working for the web service project(s).
Symptom 1:
"Unable to automatically step into the server. The remote procedure could not be debugged.
This usually indicates that debugging has not been enabled on the server.
See help for more information".
This happens when I try to F11 (stepInto) the proxy class which invokes my actual web method.
Symptom 2: Pre-setting a breakpoint in my .asmx file code on the statement that will be invoked does not work (i.e. the debugger simply doesn't stop).
Having described the situation, here's how my VStudio Solution is configured:
Service1 - project created from the VB - WEB - ASP.NET Web Service Application template; this Service1 project contains my main .asmx source code I want to debug. Web.config for this project contains compilation defaultLanguage="vb" debug="true"
ProxyService1 - a separate project created from the Windows - [VB]Class Library template; here the form1.vb file was deleted; I visited "Add Service Reference" -> Discover (Services in solution) and then in the "Compatibility" section I click "Add Web Reference". Then choosing the above Service1, I assign it a "web reference name" of WSservice1. This results in a Reference.VB file and when I build the ProxyService1 class a .DLL of the same name in the projects bin\Debug folder; this project has an App.Config file with compilation defaultLanguage="vb" debug="true"
Project1 - the main UI project with the .aspx and .vb files that call the webservice; project1 has a reference to ProxyService1.DLL; Web.config for this project contains compilation defaultLanguage="vb" debug="true". I arrive at a breakpoint in one of the files in this project called message.vb which looks roughly like this:
Public Class Message
Dim wsZipeee As New ProxyService1.WSservice1.myService
Dim dsMessage As DataSet
Public Function GetMessageByType(ByVal iMsgType As Integer) As DataSet
dsMessage = wsZipeee.GetMessageByType(iMsgType)
If I rightmouse/go to definition on the stmt above, here is the code in Reference.vb in my ProxyService1 project:
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ZipeeeWebService/Zipeee/Get Message By Type", RequestElementName:="Get Message By Type", RequestNamespace:="http://tempuri.org/ZipeeeWebService/Zipeee", ResponseElementName:="Get Message By TypeResponse", ResponseNamespace:="http://tempuri.org/ZipeeeWebService/Zipeee", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function GetMessageByType(ByVal iMsgType As Integer) As <System.Xml.Serialization.XmlElementAttribute("Get Message By TypeResult")> System.Data.DataSet
Dim results() As Object = Me.Invoke("GetMessageByType", New Object() {iMsgType})
Return CType(results(0),System.Data.DataSet)
End Function
For completeness, here is the corresponding webmethod in the .asmx file of the Service1 project:
<WebMethod(MessageName:="Get Message By Type")> _
Public Function GetMessageByType(ByVal iMsgType As Integer) As DataSet
con = New SqlConnection(sConnZipeee)
con.Open()
Everyplace in IIS I know to check and within the project properties I have checked for the proper Debug setting to be checked or set on. I've debugged other things that are set up like this but I am truly stuck on what I've missed on this "solution".
For info - if you have got here looking how to debug a .NET4 web service from VS2008/.NET3.5 app, you need to start the service in VS2010, set a break point in the service and then run your app from VS2008 as normal. The break point will be hit.
Without running the service in VS2010, you will get the error described by John above.
When I debug webservices, I usually select the option "Don't open a page. Wait for a request from an external application" in the Web section of my project properties (more info here). I also usually run the project in 2 instances of VS, one for webservice and one for client. I can put break points in the webservice and everything hits and I can see what is happening.
try to attach debugger on running aspnet_wp.exe process
I normally put of the logic to debug in class library that I can start with a console application for debug. This link will be useful too if you must debug as a service.