I'm building a DLL with several "master" objects that need access to the app LINDataContext.The DLL will serve several projects with different dataContexts, so I need the DLL can call the object that it's inside the EXE.What is the best or elegant way to do it?Edit: ClarificationCode example of what I'm trying to do:
'DLL
'---
Public MustInherit Class MasterObject(Of T As Class)
I hope the question makes sense, anyways. I'm looking to know if in VB.NET, when we call an object's constructor, is there some kind of a reference that points back to the caller? I'm interested because of a corner case where I want the object being created to first be able to validate the existence of some data in the caller before it allows itself to be created. If this validation fails, I plan on throwing an exception. This corner case will never happen at runtime unless the object being created is used improperly by a programmer. The object being created is not inheriting the object I want it to validate, so I can't do anything with the MyBase qualifier.
It's bit of a "future-proofing" issue that I have a (bad) habit of doing. Not critical -- I can always leave stern comments behind as a last resort. Wanted to know if this was possible.
I call the function GetDataTable and when it gets to the return line, I get the error message: Object reference not set to an instance of an object.
Dim DB As New DBConn Dim gd As New DataAccess.GetData Dim DT As New DataTable
[Code].....
Updated. I'll see if I can update with the DataAccess.GetData code. I didn't originally put it in there because our shop use it all the time and have no issues with it.
Form 1 contains a SWF object, which is called FlashGame (it has a movie set, which is a game)
Form 2 contains a button to set a variable on the FLashGame.
Example
Call FlashGame.SetVariable("variable will be here", 1)
That simple coding works when the button to call that SetVariable command is on the same form as the FlashGame, but I need them to be on different forms.
I am currently trying to maintain a VB6 module that it is being called from a vbscript. The module needs to have a reference to the MSScriptControl.ScriptControl COM object. However, I obtain a 80040154 error. I went ahead and registered the component using the C;WindowsSysWOW64Regsvr32.exe but then I get that the entry-point DllRegister was not found.
I'm developing this procedure using a timer object. The thing is the procedure is not in the timer's event procedure but I want it to depend on the timer's interval when executing, it's just not calling the timer procedure. How can u declare objects and use their event procedures in code.
I'm not entirely sure what to call what C# does, so I haven't had any luck searching for the VB.Net equivalent syntax (if it exists, which I suspect it probably doesn't).
In c#, you can do this: public void DoSomething() { new MyHelper().DoIt(); // works just fine }
But as far as I can tell, in VB.Net, you must assign the helper object to a local variable or you just get a syntax error:
Public Sub DoSomething() New MyHelper().DoIt() ' won't compile End Sub
Just one of those curiosity things I run into from day to day working on mixed language projects - often there is a VB.Net equivalent which uses less than obvious syntax. Anyone?
So if I create an object test, and it has a property color. When I add this object to an array list I typically can access this using myarray(0).color but intellisense doesn't 'know' that I have a 'test' object inside the array. It would let me type myarray(0).whatever but would then crash if I made typo. It seems like I should be able to let it know what type of object I am trying to work with inside the arraylist. In code maybe something like this
I am messing around with some Excel Automation just to get my feet wet and want to call some specific cells in my spreadsheet just for testing. I have one form in the project including a button. My question is how do I tell the button where to navigate to the cell to be tested?
My code for my Excel class is as follows: Public Class Waybill Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oExcel As Object = CreateObject("Excel.Application") Dim oBook As Object = oExcel.Workbooks.Open("C:\TesterXL.xls") [Code] .....
Our VB.NET application has a .NET dll, with a registered TLB file; so that VBA in Microsoft Word and Microsoft Excel can call into the application. The application functions correctly except when it is called into via MSO on Vista. This functions correctly on Windows XP machines but on Windows Vista and Windows 7 machines it is returning a 429 error. A reference to the TLB file can be assigned in the VBA References dialog box, on Vista.It doesn't appear to be a problem in our application as a simple Test libary does the same thing. Microsoft Applications have been 'Run As' Adminstrator, and Vista UAC is turned off, but I am thinking there is perhaps a security issue?
Use the "new" keyword to create an object instance & Check to determine if the object is null before calling the method. I'm reading text from a text file using the following [Code]
I have am using a Twitter streaming class library, and would like to update a listbox when a new tweet is posted. I have it all set up to the point where a message box will show when a tweet comes in, but when I try to insert this tweet into a listbox I get this error: The calling thread cannot access this object because a different thread owns it. I don't know what I need to do in order to insert this tweet.
I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:
newProperty1 - a new string property of the derived class
flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class
Code example:
Public Class derivedObj Inherits baseObj Private _newProperty1 As String[code].......
Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.
Code example:
' property names are in the string array fieldNames
'baseObjQuery is an ienumerable of baseObj
'derivedObjList is a list of derivedObj[code].....
Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?
I am getting following error whenever I want to use IIf function inside entity framework query.
LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.
Occasionally I encountered this exception message while trying to download file from a server using System.Net.FtpWebRequest and System.Net.FtpWebResponse Object.
Download a file.ftpRequest_DL.Method = WebRequestMethods.Ftp.DownloadFile get the response object Dim ftpResponse_DL As FtpWebResponse = CType(ftpRequest_DL.GetResponse, FtpWebResponse)
If I declare my object at the beggining of my page class, and instantiate it in a dropdownlist selected_index change event. Shouldn't this object be available thru out the entire page and also persist thru a postback? I lose the object in my selected date change event in my calendar.
I have an ssis package that takes a flat file and dumps it to SQL. During that process, 150 columns need to have '-' and '.' removed from them. I have done this using a Script Transformation.
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) Dim column As IDTSInputColumn90 Dim rowType As Type = Row.GetType()
[code]....
Edit I've discovered that this line is the problem
Dim strCol As String = columnValue.GetValue(Row, Nothing).ToString()
I am trying to start the process with the following parameters When I try to start it though I get an System.nullreferenceexception: Object reference not set to an instance of an object
Dim exepath As String = Application.StartupPath + "inffmpeg.exe" Dim sr As StreamReader Dim cmd As String = " -i """ + input + """ -ar 22050 -y """ + output + """" Dim ffmpegOutput As String
I have an object that is defined as a global variable based on custom class. Within that class I have an event that gets fired a certain intervals. These events are fired on the same thread as where the object is declared. How do I create a global object, but have the events within that object fire on a separate thread?
i am using VB.net 2003 and i am trying to get the number of rows of a dataset from form1 into form2 in order to use it for something else and i am getting the error"System.NullReferenceException occured...Additional information: object reference not set to an instance of an object"...my code is like this:in form1:Public x as integer= me.dataset.table.rows.count here it gives me the error