|
I was afraid it was coming to that. Sigh.
|
|
|
|
|
I've done it more times than I care to count, so I feel your pain.
VS2008 takes even longer...
|
|
|
|
|
VS2008 takes even longer...
Now that's something to look forward to!
|
|
|
|
|
Firstly sorry, I am new to vb.net.
I am writing a vb.net application to manage reports on a reporting services server. The application allows users to create datasources, upload reports from rdl files etc.
The app uploads reports ok and creates datasources but when I try to run one of the reports I get "The report server cannot process the report. The data source connection information has been deleted. (rsInvalidDataSourceReference)"
If I manually set the datasource to the shared datasource on the report server the report works fine.
From searching around I think I need to re-point the datasource in the report but I cannot figure out how to do this. I have tried using SetItemDatasource but when I try to enter the name of the datasource I get a "Type String cannot be converted to a 1 dimensional array of type datasource."
I am sure I should be doing something like:
SetItemDataSources("/ReportsFolder/ReportName", SharedDataSource)
but I cannot figure out what the SharedDataSource reference should be, I have tried "myDataSourceFolder/MyDataSourcename" but I get the above error. Please somebody put me out of my misery.
Thanks.
Richard
Its better to burn out than to fade away!
|
|
|
|
|
Realsirocco wrote: but I cannot figure out what the SharedDataSource reference should be
Did you try reading the documentation[^]?
It states that the 2nd argument is an array of DataSource[^] objects.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
This is one of my first real tasks in VB 2005 (I'm returning to VB programming after years away).In some dialogs in an app, I want to let the user display an appropriate topic in an "HTML Help" help file. (I'll add a help button to the form so that users can tell which dialogs have context-senstitive help.
I can do this with something like:
Help.ShowHelp(Me, "C:\junk\foo.chm", HelpNavigator.Topic, "Making_a_widget.htm")
where C:\junk\foo.chm is the compiled help file and Making_a_widget.htm is the name of the topic file in the source.
This is all straightforward enough but it's a one-way street - I have to be confident that my topic is there. As far as I can tell, there is no way I can check whether the topic I want is still in the help file - if I garble the topic filename like this:
Help.ShowHelp(Me, "C:\junk\foo.chm", HelpNavigator.Topic, "Waking_a_midget.htm")
the help window just shows a "404" page where the topic would have appeared. Is there any way of checking from VB whether a help topic is present (or getting a help file error status), so that I can put something in my app's error logging file?
|
|
|
|
|
The Help class doesn't expose any method to do this. I'm not aware of any Win32 API call that can do this either.
|
|
|
|
|
We have a macro that creates VB.Net classes and setup pages from system specifications.
We are moving to VB.Net 2008 and are having a problem - the macro is now crashing at random times with InvalidCastException - Unable to cast a ComObject to EnvDTE._DTE on the line
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate().
Placing a breakpoint on this line and watching the DTE shows its entries as {System._ComObject}. Sooner or later, those entries change to {System.Runtime.Interop.COMException} and the macro crashes.
If data entry is delayed by a coffee break, the crash will happen on the next entry.
Any ideas of what's going on? Is the garbage collector removing the DTE definition? How can I prevent this?
-- modified at 15:12 Wednesday 28th November, 2007
|
|
|
|
|
I copied this code exactly from the msdn site:
http://msdn2.microsoft.com/en-us/library/system.marshalbyrefobject.aspx[^]
However, it does not run for me. What am I missing? Thanks
Imports System
Imports System.Reflection
Public Class Worker
Inherits MarshalByRefObject
Public Sub PrintDomain()
Console.WriteLine("Object is executing in AppDomain ""{0}""", _
AppDomain.CurrentDomain.FriendlyName)
End Sub
End Class
Class Example
Public Shared Sub Main()
' Create an ordinary instance in the current AppDomain
Dim localWorker As New Worker()
localWorker.PrintDomain()
' Create a new application domain, create an instance
' of Worker in the application domain, and execute code
' there.
Dim ad As AppDomain = AppDomain.CreateDomain("New domain")
Dim remoteWorker As Worker = CType( _
ad.CreateInstanceAndUnwrap( _
[Assembly].GetExecutingAssembly().FullName, _
"Worker"), _
Worker)
remoteWorker.PrintDomain()
End Sub
End Class
|
|
|
|
|
sorry, to be clear it's the createinstanceandunwrap line that produce the error:
cstrader232 wrote: ad.CreateInstanceAndUnwrap( _
[Assembly].GetExecutingAssembly().FullName, _
"Worker"), _
Worker)
Could not load type 'Worker' from assembly 'WindowsApplication4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
|
|
|
|
|
Are you using VB.2008?? The page you linked to in the .NET 3.0 version.
YOu may be looking for this[^] page instead. Keep an eye on the version of the page you're looking at in the upper right corner of the content page. It'll say which version of the .NET Framework that page applies to, and give you links to other versions of the same page.
|
|
|
|
|
OK, thanks. Not yet for vb2008 for me; is it available already?
Anything that will help me get through this MarshalbyRefObject headache will be useful. I simply can't crack it.
|
|
|
|
|
VS2008 is availabe for download to MSDN subscribers. It's not out on CD/DVD yet, though it's been sent out to manufacturing.
You're using code from the .NET 3.0 version of that page. Like I said, use the code from the .NET 2.0 version of the page and you should have no problem.
|
|
|
|
|
I think I'm not a subscriber. I have a msdn password, but I don't think that's enough. Guess I'll have to wait.
|
|
|
|
|
I tried the code on the .NET 2.0 version of the page and it worked perfectly. The .NET 3.0 version doesn't work under VB.NET 2005.
|
|
|
|
|
how to know which procces['s] have access to a file in vb.net?
thnx
|
|
|
|
|
There are no classes or methods in the .NET Framework that will tell you this. This requires knowledge of calling Win32 API functions and how Windows internals work.
|
|
|
|
|
I am trying to load an application into a new domain. I have this c# code that runs fine:
AppDomain newDomain = AppDomain.CreateDomain("newDomain");
FileStream fs = new FileStream("c:\\TestClass.dll", FileMode.Open);
byte[] rawAssembly = new byte[(int)fs.Length];
Console.Write(fs.Length);
fs.Read(rawAssembly, 0, rawAssembly.Length);
Assembly asm = newDomain.Load(rawAssembly, null);
However the translation into vb.net does not:
Dim newDomain As AppDomain = AppDomain.CreateDomain("newDomain")
Dim fs As FileStream = New FileStream("c:\\TestClass.dll", FileMode.Open)
Dim rawAssembly() As Byte = New Byte((CType(fs.Length, Integer)) - 1) {}
fs.Read(rawAssembly, 0, rawAssembly.Length)
Dim asm As Assembly = newDomain.Load(rawAssembly, Nothing)
produces this error on the final line:
Could not load file or assembly 'TestClass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Both versions read the same number of bytes into the filestream.
thanks
|
|
|
|
|
I would have thought the error message made the problem quite clear.
cstrader232 wrote: Dim fs As FileStream = New FileStream("c:\\TestClass.dll", FileMode.Open)
Take out the second backslash in the filepath. In C#, two backslashes are treated as one in the final string. In VB, it's still two backslashes. This is because C# uses "\" as an escape character, whereas VB doesn't.
The declarion of the rawAssembly byte array could also be simplified.
' Beware! The CType call is a truncating conversion.
' Using this technique blindly, wihtout checking the source
' value for fit inside the targets bounds can result in a
' hard to find bug in your code!
Dim rawAssembly(CType(fs.length, Integer) - 1) As Byte
|
|
|
|
|
Thanks Dave, but that isn't the problem
I fixed the double slash to single slash, and rewrote the dim of the assembly().
The stream seems to be read OK at 3200 bytes
newdomain.Load still creates an error however.
Thanks
Dim newDomain As AppDomain = AppDomain.CreateDomain("newDomain")
Dim fs As FileStream = New FileStream("c:\TestClass.dll", FileMode.Open)
Dim rawAssembly(CType(fs.Length, Integer) - 1) As Byte
fs.Read(rawAssembly, 0, fs.Length)
Console.WriteLine(fs.Length)
Dim asm As Assembly
asm = newDomain.Load(rawAssembly, Nothing)
|
|
|
|
|
Where did this code come from? Did it come from an MSDN page? Were you looking at the correct version of the page??
Is TestClass.dll a .NET assembly that you compiled, or a DLL file you copied from somewhere else?
|
|
|
|
|
I created the dll and know exactly what's in it.
I don't think I copied the code -- I just tried it.
I appreciate your attention -- this is killing me. Can you help me with an alternative?
I can easily load the assembly into the main .exe, but I need to load it into a new Appdomain, so that I can unload it, modify it, and reload it.
I can modify the .dll as needed to allow that.
I have struggled for days with code such as this, and read everything I could find about it, all to no avail:
Dim ni As Object = newDomain.CreateInstanceFromAndUnwrap("c:\ClassLibrary1.dll", "Indicators.Indicator")
Any way to do accomplish this would be appreciated.
thanks!
Here is the .dll
Imports System
Imports System.Data
Imports System.Reflection
Namespace Indicators
<serializable()> _
Public Class Indicator
Inherits MarshalByRefObject
Public Function Calculate()
Return 99
End Function
End Class
End Namespace
|
|
|
|
|
OK. I wen't back to what you were doing, and it's not exactly like it is in the code you linked to.
You have two seperate projects, one supplying the class library, the other creating the AppDomain and loading the class library into it.
You have to supply the fully qualified name, including the namespace, to CreateInstanceAndUnwrap. The name of the DLL is also part of the namespace! You're code should look like:
Sub Main
Dim ad As AppDomain = AppDomain.CreateDomain("New Domain")
Dim as As Assembly = Reflection.Assembly.LoadFrom("C:\ClassLibrary1.dll")
Dim remoteCode As Indicator = DirectCast( _
ad.CreateInstanceAndUnwrap(as.FullName, "ClassLibrary1.Indicators.Indicator"), _
Indicator)
Console.WriteLine("Value returned: {0}", remoteCode.Calculate())
|
|
|
|
|
OK, thanks again, but I'm still not there. I still get an error on the CreateInstanceAndUnwrap line.
Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
However the .dll does seem to be read OK and the fullname of the assembly seems right.
I'm also unsure how I need to define the Indicator class type in my main code.
Dim ad As AppDomain = AppDomain.CreateDomain("New Domain")
Dim as1 As Assembly = Reflection.Assembly.LoadFrom("C:\ClassLibrary1.dll")
Console.WriteLine(as1.FullName)
Dim remoteCode As Indicator = DirectCast( _
ad.CreateInstanceAndUnwrap(as1.FullName, "ClassLibrary1.Indicators.Indicator"), _
Indicator)
I simplified the .dll too:
Namespace Indicators
<serializable()> _
Public Class Indicator
Inherits MarshalByRefObject
Public Function Calculate()
Return 99
End Function
End Class
End Namespace
thanks
|
|
|
|
|
cstrader232 wrote: Dim as1 As Assembly = Reflection.Assembly.LoadFrom("C:\ClassLibrary1.dll")
That line will only work if you give it the complete path to the .DLL you want to load. I take it you compiled your .DLL into a file called ClassLibrary1.DLL and copied it to the root of your C: drive?
|
|
|
|