Click here to Skip to main content
15,889,116 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionvb.net 2010 determine what files each user has access to Pin
dcof12-Oct-15 11:36
dcof12-Oct-15 11:36 
AnswerRe: vb.net 2010 determine what files each user has access to Pin
CHill6012-Oct-15 12:06
mveCHill6012-Oct-15 12:06 
GeneralRe: vb.net 2010 determine what files each user has access to Pin
dcof13-Oct-15 4:52
dcof13-Oct-15 4:52 
GeneralRe: vb.net 2010 determine what files each user has access to Pin
CHill6013-Oct-15 10:26
mveCHill6013-Oct-15 10:26 
QuestionVB.NET Windows Application Pin
Ranganath Deshpande8-Oct-15 10:18
Ranganath Deshpande8-Oct-15 10:18 
AnswerRe: VB.NET Windows Application Pin
Richard Andrew x648-Oct-15 10:38
professionalRichard Andrew x648-Oct-15 10:38 
QuestionAccess tablet webcam Pin
Member 120415567-Oct-15 17:18
Member 120415567-Oct-15 17:18 
QuestionProblems implementing MEF Pin
Kenneth Haugland7-Oct-15 8:43
mvaKenneth Haugland7-Oct-15 8:43 
I created a simple application that uses an interface to implement MEF (and yes its a stupid and simple example, or so I thought):
VB
Imports System.ComponentModel.Composition

<InheritedExport(GetType(IMathFunctions))>
Public Interface IMathFunctions
    Function DoMath(ByVal Num1 As Double, ByVal Num2 As Double) As Double
End Interface

So In the same project I have one class that uses the interface:
VB
Imports WpfImportedFiles
Imports System.ComponentModel.Composition

<Export(GetType(WpfImportedFiles.IMathFunctions))>
Public Class Substract
    Implements WpfImportedFiles.IMathFunctions

    Public Function DoMath(Num1 As Double, Num2 As Double) As Double Implements IMathFunctions.DoMath
        Return (Num1 - Num2)
    End Function
End Class

And I load this into the program using this code:
VB
Imports System.Collections.Generic
Imports System.Linq
Imports System.ComponentModel.Composition
Imports System.ComponentModel.Composition.Hosting
Imports System.Reflection
Imports System.IO

Public Class Importer
    <ImportMany(GetType(IMathFunctions))>
    Private operations As IEnumerable(Of IMathFunctions)

    Public Sub DoImport()
        'An aggregate catalog that combines multiple catalogs
        Dim catalog = New AggregateCatalog()
        ''Adds all the parts found in all assemblies in 
        ''the same directory as the executing program

        ''Fill the imports of this object
        Dim asm = Assembly.LoadFrom("C:\Users\ ... \LibImportedClasses.dll")
        Dim catalog2 As New AssemblyCatalog(asm)
        Dim catalog3 As New AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly())
        catalog.Catalogs.Add(catalog3)
        catalog.Catalogs.Add(catalog2)
        Dim container As New CompositionContainer(catalog)

        container.ComposeParts(Me)

    End Sub

    Public ReadOnly Property AvailableNumberOfOperations() As Integer
        Get
            Return (If(operations IsNot Nothing, operations.Count(), 0))
        End Get
    End Property

    Public Function CallAllComponents(a As Double, b As Double) As List(Of Double)
        Dim result = New List(Of Double)()
        For Each op As IMathFunctions In operations
            result.Add(op.DoMath(a, b))
        Next
        Return result
    End Function
End Class

This works well for the class that is inside the original project, except for one thing; It gets loaded twice, and I don't understand why.

The other question is, how do I load a lib file that is in a separate project (i.a. the interesting case). I could not get it to work, but managed to load the assembly, that did contain the class I wanted to load, but I couldn't use it.

I hope that you could assist me in answering the two (hopefully) simple questions.
AnswerRe: Problems implementing MEF Pin
Brisingr Aerowing7-Oct-15 9:15
professionalBrisingr Aerowing7-Oct-15 9:15 
GeneralRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 9:32
mvaKenneth Haugland7-Oct-15 9:32 
QuestionRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 18:57
mvaKenneth Haugland7-Oct-15 18:57 
AnswerRe: Problems implementing MEF Pin
Kenneth Haugland7-Oct-15 20:55
mvaKenneth Haugland7-Oct-15 20:55 
Questionmouse hover over button to show sliding label and don't hide it until mouse leaves the panel. Pin
Pravas Ranjan7-Oct-15 3:11
Pravas Ranjan7-Oct-15 3:11 
QuestionCompiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 1:27
DAH_bham6-Oct-15 1:27 
AnswerRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 1:49
mveRichard Deeming6-Oct-15 1:49 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 2:33
DAH_bham6-Oct-15 2:33 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 2:37
mveRichard Deeming6-Oct-15 2:37 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 2:38
mveRichard Deeming6-Oct-15 2:38 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Dave Kreskowiak6-Oct-15 5:14
mveDave Kreskowiak6-Oct-15 5:14 
SuggestionRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Richard Deeming6-Oct-15 5:20
mveRichard Deeming6-Oct-15 5:20 
GeneralRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
DAH_bham6-Oct-15 3:36
DAH_bham6-Oct-15 3:36 
AnswerRe: Compiled code cannot create Excel.Application, Interpreted is fine Pin
Dave Kreskowiak7-Oct-15 4:33
mveDave Kreskowiak7-Oct-15 4:33 
QuestionStandard VB 2013 progress bar animation weirdness Pin
Member 15839634-Oct-15 8:53
professionalMember 15839634-Oct-15 8:53 
QuestionRe: Standard VB 2013 progress bar animation weirdness Pin
Brisingr Aerowing4-Oct-15 13:09
professionalBrisingr Aerowing4-Oct-15 13:09 
AnswerRe: Standard VB 2013 progress bar animation weirdness Pin
Member 15839634-Oct-15 22:16
professionalMember 15839634-Oct-15 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.