ActiveSkin GDI Leak - gdi

ActiveSkin used in all forms of our application, which has been originally developed in VB6 and later migrated into VB.NET.
This unmanaged code wrapped into Interop, and declared in our class SkinForm, which is inherited by all forms in the our application.
Now we have the following code in the method OnFormClosing in our class:
MyBase.OnFormClosing(e)
If Not ActiveSkin Is Nothing AndAlso Me.Controls.Contains(ActiveSkin) Then
Me.Controls.Remove(ActiveSkin)
End If
ActiveSkin = Nothing
Where ActiveSkin - it is a wrapper for SkinForm class from ActiveSkin library.
The GDI leak occurs after each form closing.
If we add the following code:
ActiveSkin.Dispose()
after removing it from the controls collection. Leak disappears. But at the first close of any form, we get the following message (only once during the application execution):
“Warning! This application was created with trial version of ActiveSkin control.
You can register ActiveSkin here: http://www.softshape.com/activeskin”.
Of course we have a license for library .
Do you have any thoughts?
Thanks.

Related

How can I add Console dll file in web application?

By following the CHATGPT guidelines I added a Console file dll (Inboundnightlybatchfile is my console file) in the bin folder of my web application. To access the dll need to import in our application. So I write this using Inboundnightlybatchfile; But the dll file name does not appear in the IntelliSense, and it throws a compile time error.
I want to add the Console file dll to an Web application
Well, HOW do you share ANY code in your existing application, or code from "other" applications?
why of course you have/put that code in a class.
I mean in your project now, how do you use/enjoy a bunch of helper code and routines?
You wind up with a class, and then in code create a instance of that class.
So, say I have a class that holds some information about a hotel?
Then you add a class to your project, and then simple use that class in code.
So, say this class:
Public Class Hotel
Public HotelName As String
Public City As String
Public HotelDescripiton As String
Public FirstName As String
Public Lastname As String
Public ReadOnly Property FullName As String
Get
Return FirstName & " " & Lastname
End Get
End Property
End Class
Then in code, you can use that "code"
eg:
Dim OneHotel As New Hotel
OneHotel.HotelName = "Super 8 Hotel"
OneHotel.FirstName = "John"
OneHotel.Lastname = "Smith"
Debug.Print(OneHotel.FullName)
Output:
John Smith
Same goes for a console application. If you want share that code, then move the console code you want to share to a class.
Say I have this console application. When I run it, it will display all my drives on the computer.
So, from command prompt I have this:
So, now lets say I want to use above in my web site - to display/list all the hard drives.
So, the code for above console application is this:
Sub Main()
Dim cMyCode As New clsSharedCode
Dim sDriveList As List(Of String)
sDriveList = cMyCode.GetDrives
For Each s As String In sDriveList
Console.WriteLine(s)
Next
End Sub
But, the "working" code for that console been moved to a class called clsSharedCode.
That is this:
Imports System.IO
Public Class clsSharedCode
Public Function GetDrives() As List(Of String)
Dim DriveList As New List(Of String)
Dim allDrives As DriveInfo() = DriveInfo.GetDrives
For Each d As DriveInfo In allDrives
Dim s As String
s = $"Drive:{d.Name} Volume:{d.VolumeLabel} Type:{d.DriveType} Ready:{d.IsReady}"
DriveList.Add(s)
Next
Return DriveList
End Function
End Class
Ok, so now lets use above in our web site.
We simple set a reference to vbconsole.exe.
So, now this web page markup:
<h3>Drives on computer</h3>
<asp:ListBox ID="ListBox1" runat="server" Height="223px" Width="423px">
</asp:ListBox>
code behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim cConsoleCode As New VBConsole.clsSharedCode
Dim sDriveList As New List(Of String)
sDriveList = cConsoleCode.GetDrives
For Each sDrive As String In sDriveList
ListBox1.Items.Add(sDrive)
Next
End If
End Sub
And then we get this:
So, to "share" code? How this works EVEN with a simple plain jane console application is quite much the same as you "always" done this.
This does mean/suggest that the working code in your console application should be moved out to a shared code class that BOTH the console application, and now your web application can use and enjoy.
But, be a a web site, or even a simple console application?
The why and how of sharing the code quite much is the same in .net. You share code by using a object approach, and this is quite much the WHOLE foundation as to how .net code works - including that of sharing code between systems and applications.
So, in my web application, I simple set a reference to vbconsole.exe, and now I am free to use + consume any code in that console appliation. however, as noted, like you ALWAYS done to share code? You will as a general rule move that code out to a class, and then any other application is free to consume + use that code by using the public class code you have in that application. So, that MySharedCode class in the console application can now be used by any other .net application, include that asp.net web site.
so, .net is "primarily" a object based system, and this is the main pillar and foundation of how you re-use and share .net code. You share such code by creating class(s) with that code, so then your existing application (the console application) can use those class(s), and as above shows, by a simple reference to the vbconsole.exe application, the web site can also use + enjoy + consume that code also.
So, becasue a class forces you to seperate out the UI parts from the code parts, then even adopting this approach in a simple console application means that such code can be used + consumed by any type of application. you can write another console applcation, and reference our above console application and use that code.
but, we can also create a windows desktop program, and again reference the vbconsole.exe application. And so can our web based applcation.
And even MORE amazing? You can consume the above class in c#, or vb.net, and again it don't matter!

Visual Studio 2008 ASP.NET Website error: Handles clause requires a WithEvents variable defined in the containing type or one of its base type

I'm new to the job and trying to get accustomed to VB.NET and Visual Studio 2008. I came from VS 2015 - 2017 and C#.
I downloaded a project from Subversion Source Control and I tried to run it. I get this weird error that reads: "Handles clause requires a WithEvents variable defined in the containing type or one of its base type". I tried several solutions around the web and SO without avail. I tried solutions from here, here and here without any luck. Some of the solutions has to do with the aspx.designer.vb file but unlike projects, VS 2008 ASP.NET websites doesn't have these type of files. I tried to re-create the button and the code behind with no luck. The error persists and the error only refers to one button in particular. Others buttons in the same page are working fine.
How I'm supposed to fix this? Please! Thank you!
Without seeing the code, it is impossible to say why the error occurred but here's one of the reasons that might cause this issue.
You are trying to use evets of a type that is not declared to use events of
Consider the below sample :
Dim txbx as New TextBox
Here I created a new instance of the type TextBox. As we know a textbox has may events, so if you try to access the events of the above declared textbox as follows :
Private sub txtbx_TextChanged(……….) Handles txtbx.TextChanged
Then you will get the error.In order to access the events of a code-behind declared type/control, you must WithEvents when you define/declare the variable of the type :
Dim WithEvents txtbx as New TextBox
Now you can easily access all the evets of the type. As I said earlier that this may not be your issue but if it is, then I hope it helps :)
or
create anew page , copy-paste all codes from previous page(except page directives from HTML ) and rebuild your project ...

Glimpse showing empty Execution/SQL tab when using structuremap container for asp.net mvc5

I am trying to integrate Glimpse into my asp.net mvc-5 application. I'm using structuremap to inject constructor dependencies in my Application_Start method.
_structureMapResolver = new StructureMapDependencyResolver(container);
DependencyResolver.SetResolver(_structureMapResolver);
I am getting empty Execution and SQL tabs. I tried commenting the above lines and loaded a regular empty constructor page, and I started getting results.
how do I get this data in this tab keeping structure map intact?
(let me know if you want the code for StructureMapDependencyResolver class.)
Thanks already.

"Argument not specified for parameter" using Ninject in web forms

Just to re-iterate the title, this is web forms and not mvc. Also it's using vb.net.
I have used nuget to add ninject.web to my project. I have configured NinjectWebCommon's "RegisterServices" method as follows:
Private Shared Sub RegisterServices(kernel As IKernel)
kernel.Bind(Of ilbdUOW)().[To](Of lbdUOW)()
End Sub
Everything compiles clean. When I run the simple web form (.aspx page, no master page), I get the following error:
BC30455: Argument not specified for parameter '_uow' of 'Public Sub New(_uow As lbD.data.lbdUOW)'.
And it points to line 52 in the compiled code:
Line 51: Public Sub New()
Line 52: MyBase.New
Line 53: Dim dependencies() As String
which (I believe) comes from the top of the .aspx page when compiled, where I have the following code for the "new" constructor:
<Inject()> _
Public Sub New(_uow As ilbdUOW)
Uow = _uow
End Sub
(well, I say "I believe" but I know it is as if I change the "ilbdUOW" from the interface to the class of "lbdUOW" it changes the error message accordingly so that's definitely where it's coming from)
If I put a debug stop on the "uow = _uow" line in my "New" constructor and also another debug stop in the "RegisterServices" method in the NinjectWebCommon file, the debugger only stops on the "RegisterServices" debug point and never gets to hit the debug stop in the main .aspx page.
I'm now completely lost. I am trying to get my head around what is relatively new to me and I thought I was pretty much getting there. My understanding is that the code in "RegisterServices" in NinjectWebCommon will recognise that I'm requiring an instance of my "ilbdUOW" interface when it is referenced in a constructor (such as my "new" constructor in my .aspx page) and will inject it automatically, thus making the unit of work instance available for me to access the database with.
If anyone can point me in the right direction I'd be really grateful, thanks.
Edited to add:
#mipe34
Not on the "new" constructor, no:
Public Sub New(ByVal repositoryProvider As IRepositoryProvider)
MyBase.New()
CreateDbContext()
repositoryProvider.DbContext = DbContext
_RepositoryProvider = repositoryProvider
End Sub
I have also set up the "RegisterServices" section to map those interfaces too, but it makes no difference to the error I get whether those extra mappings are in there or not, it seems to fail before I get to that point.
I have had these lines in and out of the "RegisterServices" section and it makes no difference:
kernel.Bind(Of RepositoryFactories)().[To](Of RepositoryFactories)().InSingletonScope()
kernel.Bind(Of IRepositoryProvider)().[To](Of RepositoryProvider)()
WebForm are created by ASP.NET not Ninject You can't use constructor injection on WebForms. You have to do property injection instead.

does Server.CreateObject("Microsoft.XMLDOM") use activex?

im planning on using asp classic to create an XML file for users to download, however i am not able to do this via activex. upon checking around, i noticed that one of the more common statements is
Server.CreateObject("Microsoft.XMLDOM")
does it use activex?
Ultimately "ActiveX" is just some marketing spin for COM components. (Putting X on the end of words back then is the same as putting i at the start of words today)
However over time ActiveX has become associated more with control components, COM components that have some UI, which clearly you can't use server-side.
The place to start is with
Dim xml: Set xml = CreateObject("MSXML2.DOMDocument.3.0")
This is a COM object so strictly speaking it is an ActiveX component however as with other components like ADODB it works fine in server side code like ASP

Resources