What file type does a .Net Class Library project compile to?

H

Hal Gibson

What file type does a .Net Class Library project compile to?

I gather .Net Class Libraries serve the same function as VB6 ActiveX dlls?


--Hal
 
Z

zacks

What file type does a .Net Class Library project compile to?

I gather .Net Class Libraries serve the same function as VB6 ActiveX dlls?

--Hal

Not activex dll, just a plain ordinary dll.
 
H

Hal Gibson

So, what file extension does the compiled library have?

I know it's an odd question, but I had so many errors when I ran my ActiveX
dll project through the upgrader, I thought I'd just ask rather than waiting
to see once I had them eliminated.

(I know .Net can access VB6 dlls via Interop, but that won't do much good if
Visual Studio 6 won't run future versions of windows).

What file type does a .Net Class Library project compile to?

I gather .Net Class Libraries serve the same function as VB6 ActiveX dlls?

--Hal

Not activex dll, just a plain ordinary dll.
 
H

Herfried K. Wagner [MVP]

Hal Gibson said:
So, what file extension does the compiled library have?

DLL, "Foo.dll", for example. However, note that .NET creates CLR-based
DLLs, not ActiveX/COM DLLs.
 
F

Family Tree Mike

Hal Gibson said:
So, what file extension does the compiled library have?

I know it's an odd question, but I had so many errors when I ran my
ActiveX dll project through the upgrader, I thought I'd just ask rather
than waiting to see once I had them eliminated.

(I know .Net can access VB6 dlls via Interop, but that won't do much good
if Visual Studio 6 won't run future versions of windows).


Class libraries when compiled will create a .dll file.
 
H

Hal Gibson

Would CreateObject also work to instantiate a .net dll that wasn't
specifically referenced in the project?

What file type does a .Net Class Library project compile to?

I gather .Net Class Libraries serve the same function as VB6 ActiveX dlls?

--Hal

Not activex dll, just a plain ordinary dll.
 
F

Family Tree Mike

Hal Gibson said:
Would CreateObject also work to instantiate a .net dll that wasn't
specifically referenced in the project?



Not activex dll, just a plain ordinary dll.


Activator.CreateInstance is the equivalent to CreateObject in vb6 for .net
classes. The key difference is you have to load the .Net assembly with
Assembly.LoadFrom("somefile.dll"); in your code. There is no magical lookup
akin to COM unless the dll is installed into the GAC.
 
M

Michel Posseth [MCP]

Family Tree Mike said:
Activator.CreateInstance is the equivalent to CreateObject in vb6 for .net
classes. The key difference is you have to load the .Net assembly with
Assembly.LoadFrom("somefile.dll"); in your code. There is no magical
lookup akin to COM unless the dll is installed into the GAC.


And add to this the need for an interface ,
while with CreateObject in VB6 you used late binding an you thus only needed
to type the Field / Method names correctly ,
However although i personaly would not recomend it it is possible to use
creatobject through ( just create a COM class ) in .Net , this would also
mean you need to put option strict to Off and you have to go twice to
marshal boundries ,,, so although it is technicly possible it is in my
opinion a no go area ( unless the called dll is a legacy ( VB6 ) dll )

As Mike already told we have now Reflection to do the .Net equivalant of
late binding

To give you an idea ,

In the company i work for we have a production system where all our BL
classes share this interface

'--------------------------------------------------------------------------------------

'---

'--- Purpose : Provide an generic interface for the Queu

'---

'--- Made by : Michel Posseth [MCP]

'--- For : ista netherlands

'--- Date : 20-11-2006

'--- Revissions :

'---

'--- Remarks : Do not break the interface signature !!

'--- you may extend but never remove property`s or methods

'---

'--------------------------------------------------------------------------------------

Option Strict On

Option Explicit On

Public Interface IiQueuObject

Sub StartProcessing()

Property Parameters() As String

Property ProcessId() As String

Event eFinished(ByVal ProcessId As String, ByVal msg As String)

Event eError(ByVal ProcessId As String, ByVal msg As String)

Event eProcessCancelled(ByVal ProcessId As String, ByVal msg As String)

Property CancellProcess() As Boolean

End Interface



A windows service , ( actually a by me written Queue service wich can even
run multiple queues in multiple priorities and orders etc etc etc ) now
queries a database where it only needs to get the path to the dll that
needs to be started

and throw it to this method



'--------------------------------------------------------------------------------------

'---

'--- clsGetObjectFromFile

'---

'--- Purpose : start returns an initiated ista.IiQueuObject

'---

'--- Made by : Michel Posseth [MCP]

'--- For : ista netherlands

'--- Date : 14-11-2006

'--- Revissions : 21-11-2006 : AssPath ingebouwd voor flexibiliteid

'--- 05-12-2007 upgrade naar framework 3.5

'---

'--------------------------------------------------------------------------------------

Option Strict On

Option Explicit On

Imports System.IO

Public Class clsGetObjectFromFile

''' <summary>

''' Laad een object by zijn assembly naam en class naam

''' het te laden object moet een ista.IiQueuObject interface bezitten

''' </summary>

''' <param name="vstrAssemblyName">Name of the VSTR assembly.</param>

''' <param name="vstrClassName">Name of the VSTR class.</param>

''' <returns></returns>

Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, _

ByVal vstrClassName As String) As ista.IiQueuObject

'<21-11-2006 MP>

If vstrAssemblyName.StartsWith("[AssPath]") Then

Dim appath As String = My.Application.Info.DirectoryPath

vstrAssemblyName = vstrAssemblyName.Replace("[AssPath]", "")

vstrAssemblyName = Path.Combine(appath, vstrAssemblyName)

End If

'</21-11-2006 MP>

Dim objAssembly As Reflection.Assembly

If Not My.Computer.FileSystem.FileExists(vstrAssemblyName) Then

ServMain.WriteLogentry("Assembly niet aanwezig : " & vstrAssemblyName,
EventLogEntryType.Error)

'de assembly is niet aanwezig op deze lokatie

Return Nothing

End If

objAssembly = Reflection.Assembly.LoadFrom(vstrAssemblyName)

'voer een cast uit naar ista.IiQueuObject interface

Try

LoadMeByName = DirectCast(objAssembly.CreateInstance(vstrClassName),
ista.IiQueuObject)

Catch ex As Exception

ServMain.WriteLogentry("Assembly bezit niet de juiste interface : " &
vstrAssemblyName, EventLogEntryType.Error)

Return Nothing

End Try

If LoadMeByName Is Nothing Then

Dim msg As String

msg = "Assembly : " & vstrAssemblyName & Environment.NewLine & _

"Type : " & vstrClassName & " is niet gestart om onduidelijke reden"

ServMain.WriteLogentry(msg, EventLogEntryType.Error)

'geen error gewoon niets terug geven

'wanneer we dus iets anders hebben als een Nothing pointer

'dan hebben we een geinitialiseerd object

Return Nothing

End If

End Function

End Class



I hope this gives you some ideas



regards

Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top