|
Hello,
I've developed a .net dll and made it com Visible and also i've added register for com interoperability.
I need this COM object in visual basic 6.0.
It works fine, when i build the .net component. It generates a .tlb file and i could get my result as expected.
But when i executed this on the other machine it shows error.
i've copied my dll to the other machine and generated a .tlb file by using 'regasm'.
I can see the tlb file in references of my Visual Basic 6, but it is giving error that "Could not load file or assembly 'thirdpartydll' or one of its dependencies".
i've tried by registering with GAC but could not solve my problem .
please help me !
Thanks,
|
|
|
|
|
Did you reference any other libraries in your control?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
i did not add any library references in vb6.
|
|
|
|
|
Karthik Reddy wrote: I've developed a .net dll and made it com Visible
Which assemblies does your .net dll reference?
--edit;
Rephrased
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
modified 21-Aug-12 6:49am.
|
|
|
|
|
No. He meant did you have to add a reference to anything in your VB.NET code that you wrote this COM component in?
|
|
|
|
|
I did not add the references in vb6 application.
but my component has references in it.
do i need to add those references which are in my component ?
|
|
|
|
|
Karthik Reddy wrote: do i need to add those references which are in my component ?
You do indeed. Anything used by your dotNet component must exist in any environment that you deploy the component to. Dependencies are not going to be compiled into your assemblies.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Not quite. Any unresolved references in the VB.NET COM component will NOT be resolved by adding a reference in the VB6 project using the component.
He's still stuck on adding references to his VB6 code to fix this, which we all know won't work.
|
|
|
|
|
Sorry. Maybe I wasn't clear enough. If the assemblies required by the COM-Interop assembly are available in either the install directory of the component that requires it or in the GAC, then his reference of the COM component through VB6 should work. I'm working from memory here as I haven't done anything like this in a couple of years.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Oh, no, you were clear. I'm just saying if the assemblies were present, he wouldn't be have the problem in the first place and hence wouldn't need to add references to them in his VB6 project.
|
|
|
|
|
Understood. I reread your response and that was clear. I just must have read it too quickly. Cheers.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
That's probably why it's claiming that one of the dependencies cannot be found; your component references something that's not available (or registered!) on the target-machine.
VB6 isn't interested in what your component uses; but the things that the component uses "should" be available on the target-machine. The .NET runtime will then load them for you.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you Eddy and Marcus Kramer..
Some how i got the result not upto the mark though.
|
|
|
|
|
Again, we're not talking about your VB6 code at all. All we're interested in is the VB.NET code you wrote to write this component.
If you added references in your VB.NET project to other libraries, you MUST copy those libraries over to the target machine at install time for your component. If your component code is using something in a library, how is the code going to work if the item referenced is not on the machine?? It'll throw the very error you're getting, specifically, the part about "or one of its dependencies".
You do NOT need to add any references in your VB6 code, other than the one to your COM component. Those references won't work for your component anyway. You DO need to make sure that everything your component uses is installed on the target machine.
|
|
|
|
|
Let's put things in other words, maybe you'll understand then.
You created a dll in .Net for COM interop, let's give it a name here: MyCOM.dll.
When you created MyCOM.dll, you referenced ThirdParty.dll. That means, MyCOM.dll depends on ThirdParty.dll to be available.
On your machine - where you developed MyCOM.dll - ThirdParty.dll is available.
But on the other machine, it is not.
How to solve: copy ThirdParty.dll into the same directory as MyCOM.dll.
|
|
|
|
|
|
As the subject states I am having some trouble with implementing a delegate to solve this issue that I am having.
The error that I am receiving is that cross-thread operation is not valid. I have windows form that we will call Form1 for example that has many buttons. For one those buttons opens up another form that we will call for this example Form2 that will display some data. Form2 has a COM obj that is similar to a datagridview, but it displays the data which is similar to a pdf viewer that can allowing zooming and formatting. Before I start posting where my problem is in code I did some searches and everyone suggests to use Delegates to prevent the cross-threading problem. I am quite new to delegates so I have been reading the MSDN Documentation[^] about delegates, but I am still not understanding it quite well. Also, I have read this great article A Beginner's Guide to Delegates[^] about 3 times. I understand it's a introduction article.
Here is snippet of code that is causing me problems while I am using delegates (incorrectly???)
Note: This snippet of code is from Form1
Public Delegate Sub StoreDetailedOutputID(ByVal strID As String)
Private strKey1 As String
Private Sub AnalysisResultsEngineName(ByVal strEngineName As String)
frmAnalysis_Results_Form.Set_Engine_Name(strEngineName)
End Sub
Private Sub cmdSpreadSheetOutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSpreadSheetOutput.Click
strKey1 = "Please work!"
Dim dEngineName As StoreDetailedOutputID
dEngineName = AddressOf AnalysisResultsEngineName
dEngineName.Invoke(strKey1)
End Sub
With that I have a few additional questions so that I may understand what delegates are all about.
-Where should the delegate be created within my program? Form1? Form2?
-Should the Delegates be created on both forms?
-Should I use BeginInvoke instead of Invoke?
-Is Delegates indeed the correct route to go? Should I use Threading?
Any help to clarify my misunderstanding of delegates would be greatly appreciated.
|
|
|
|
|
A Delegate is a method-pointer, you could look at it as an interface on a method-only-level. That means that it defines a Type , like an Integer , but not for data, but for methods. That means you can store a reference to a method.
When a single-threaded application is executed, it's the UI-thread or the main-thread that builds the controls. A thread executes the instructions in the code one after another. That's why you sometimes see a form go completely white when it is doing a lot of processing; the UI thread is too busy to do the drawing. To prevent that from happening, and have a responsive UI, we do the heavy work on a separate thread.
Clark Kent123 wrote: -Where should the delegate be created within my program? Form1? Form2?
On the place where you intend to call it, you'll need an instance. That instance could be passed using a parameter, as a Delegate is a Type that "acts" as a variable.
Clark Kent123 wrote: -Should the Delegates be created on both forms?
No, but the delegate is often public, so that it's Type can be used in other forms (from where it's called, for instance)
Clark Kent123 wrote: -Should I use BeginInvoke instead of Invoke?
Invoke should execute it on the same thread; that Exception you mention should only occur when you use BeginInvoke , as that creates a new thread. In that case you'll also need the Invoke-pattern[^].
Clark Kent123 wrote: -Is Delegates indeed the correct route to go? Should I use Threading?
You should be able to answer that by yourself now; threading is for heavy tasks, delegates are method-variables. Here's an example that uses both;
Imports System.Windows.Forms
Imports System.Threading
Public Delegate Sub MyCallbackProto(Count As Integer)
Public Class TheThreadClass: Inherits Object
Private mySomeCallbackRoutine As MyCallbackProto
Private myThread As Thread
Public Sub New(aSomeCallback As MyCallbackProto)
mySomeCallbackRoutine = aSomeCallback
myThread = New Thread(AddressOf Work)
myThread.Start
End Sub
Public Sub Work()
For i As Integer = 0 To 100
Thread.Sleep(50)
mySomeCallbackRoutine(i)
Next
Application.Exit
End Sub
End Class
Public Class Form1: Inherits Form
Private myProgressBar As New ProgressBar
Private myThread As TheThreadClass
Public Sub New()
Controls.Add(myProgressBar)
myThread = new TheThreadClass(AddressOf OnUpdate)
End Sub
Sub OnUpdate(Count As Integer)
myProgressBar.Value = Count
End Sub
End Class
Public Class MyApp
Public Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
Another cool intro to delegates is the A Beginner's Guide to Delegates[^] article. There is a series (5 articles I believe) on threads called Beginners Guide to Threading in .NET: Part 1 of n[^].
Enjoy
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I appreciate that answer. Yeah, I do agree that by now I should be able to answer whether threading or Delegates is the way to go. I am going to stick with Delegates and take some time to digest all this information. As well as go reread all those delegate articles.
I am sure later on I will look back and think of how easy it was to set this up.
Thanks again.
|
|
|
|
|
Clark Kent123 wrote: I appreciate that answer.
..which motivates to answer questions. Thanks for the feedback
Clark Kent123 wrote: I do agree that by now I should be able to answer whether threading or Delegates is the way to go.
That depends on how good my explanation was; if it isn't clear, then my explanation wasn't what it should have been. I agree that I kinda buried you under a lot of information.
Threads are for long-running, CPU intensive tasks. Delegates are variables for methods.
Depending on what you are doing to Form2 (from the point of view from Form1), you might need an event, not just a delegate. Let's try it another way;
- Are you trying to "inform" another class that something changed? (event)
- Are you trying to "execute" another method from another class? (delegate)
- Are you trying to "run" something that seems to hang your app? (threads)
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Quote: Depending on what you are doing to Form2 (from the point of view from Form1), you might need an event, not just a delegate. Let's try it another way;
Are you trying to "inform" another class that something changed? (event)
Are you trying to "execute" another method from another class? (delegate)
Are you trying to "run" something that seems to hang your app? (threads)
In all honesty, I am just trying to prevent the error message from popping up. So I was not paying too close attention on what Delegates were, but had the mind set of copy and paste sample code and hope the error goes away.
I think the "informing" the other class that something has changed might be the what I want to do. Upon reading and reflecting (something new this time ) on what delegates can do I think a delegate event might be beneficial in my scenario. I think. It's an experiment I want to try. I stumbled upon this MSDN VB related documentation[^] that lead me to thought of trying the delegate event.
My mind set of programming has been linear that the idea of something asynchronously is foreign to me and it's taking me a while to grasp how to implement it in my app. I get the concept of what it does, but I am not yet there of saying "Oh, this would be a perfect place to make this method async with threads" or "Wait, this needs a delegate". I hope that makes sense.
|
|
|
|
|
Clark Kent123 wrote: In all honesty, I am just trying to prevent the error message from popping up. So I was not paying too close attention on what Delegates were, but had the mind set of copy and paste sample code and hope the error goes away.
I quickly dropped that method of learning, as it becomes frustrating very quickly. Incomplete samples, fishing out the unrelated parts, the "cool" feature you missed because the example used a simpeler overload..
Clark Kent123 wrote: I think the "informing" the other class that something has changed might be the what I want to do.
Hehe, I was afraid that this would be the answer; there's a specialized form to use the delegate, called the event. If your class where to "notify" another class that it has finished loading that huge text-file, you'd typically raise an event (RaiseEvent[^]), something called "OnLoadFinished" or something like that.
Clark Kent123 wrote: I am not yet there of saying "Oh, this would be a perfect place to make this method async with threads" or "Wait, this needs a delegate".
All too well; especially if a technique is still abstract in ones mind, often the case with design-patterns. To make it worse, there are usually multiple ways to achieve something, often with no clear "correct" way, but multiple trade-offs to go either here or there.
Clark Kent123 wrote: My mind set of programming has been linear that the idea of something asynchronously is foreign to me and it's taking me a while to grasp how to implement it in my app.
As a quick rule-o-thumb, anything that takes more than 0.5 second to complete, should be on it's own thread. Loading large pictures, parsing text-files, loading large tables; all of those would be candidates for their own thread (ideally with a progress-indication).
Learning threading, delegates and events all at once is a bit much to dive into. I suggest you pick one of the three and try to create the smallest console-app possible to see it in action. MSDN is your friend here
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi everyone,
I am trying to find out how to organize some documents I have for work so that my colleagues could use them efficiently.
I thought of creating a table with the documents' names, hyperlinks and the corresponding keywords.
My colleagues should be able to retrieve the right documents by choosing some of those keywords.
In order to do that I thought that the best idea would be to insert some checkboxes representing the keywords in an Excel file on the network, and when you check some of the checkboxes only the documents having those keywords associated would be listed with the hyperlinks to where to be accessed.
Does this sound complicated? The problem is that I studied VBA and other programming languages many years ago in university so my knowledge now kind of equals to "zero". Is there any sample code I could start with or some tutorials on how to do this? Is there an easier way to do this?
I would very much appreciate your opinions.
|
|
|
|
|
My suggestion would strongly depend on the way how you want to store and maintain your list.
Using Excel / VBA, your list may be easy to maintain in Excel itself, but proper coding might be hard – at least from a certain point where you want to make your tool as user friendly as possible (with forms, checkboxes etc.).
Using VB.NET (you're in the VB.NET forum here) you have the free Express Versions to build a perfect solution e.g. with generic lists. The task itself sounds easy, but you have to dive into VB.NET a bit, as there are other basic tasks connected with it (e.g. in which format would you store your data, how would you read them, which controls would you use to present them, how would you present the data to your users, etc).
If you choose to use VB.NET, you might want to download VB.NET Express and read some articles on the net (many of them also have code samples) about
- how to create a form
- how to read/write text or xml files
- how to use generic lists
|
|
|
|
|
That does not sound complicated, but maybe an overview of what VB is all about would be a good start. Here is a link to help you get your zero VB knowledge to something above zero. This way you might think of additional solutions on how to get what you want.
Channel9 MSDN: Visual Basic Development for Absolute Beginners[^]
Let me know if this helps.
|
|
|
|