Calling Method From App_Code?
Mar 26, 2012I have method that exisit in APP_CODE class and I want to call it from Class Library what is the best way to do that?
View 1 RepliesI have method that exisit in APP_CODE class and I want to call it from Class Library what is the best way to do that?
View 1 RepliesDoes calling the Dispose method on a Windows.Forms.Timer call it's Stop method? Or should I stop the timer before I dispose it?
View 5 RepliesWhen I am loading an Assembly dynamically, then calling a method from it, I appear to be getting the method from Assembly executing before the code in the method that is calling it.It does not appear to be executing in a Serial manner as I would expect. Can anyone shine some light on why this might be happening. Below is some code to illustrate what I am seeing, the code from the some.dll assembly calls a method named PerformLookup. For testing I put a similar MessageBox type output with "PerformLookup Time: " as the text. What I end up seeing is:
First: "PerformLookup Time: 40:842"
Second: "initIndex Time: 45:873"
Imports System
[code].....
Let's say I have a page Test.aspx along with test.aspx.vb.Test.aspx.vb contains a class name "TestClass". In that class I have method1(), method2() and method3()I need to be able to call one of those methods, but I can't hard code it, the method to be executed comes from a string.
I can't do
Select Case StringContainingTheNameOfTheDesiredMethod
Case "Method1"
[code]...
I am indifferent if you are a VB.NET or C# or other .NET developer. I have a FACTORY class like the following:
[Code]...
Basically i've got a web service that i'm trying to put some kind of usage logging in. To do this i've created a class with a logging method. I instatiate the class on the service and then call the logging method in each of the web methods.
[Code]...
I have a .dll file (Interop.ACTMULTILib.dll) that I use to connect to a PLC. This .dll contains a sub called ReadDeviceBlock2(byval devicename as string, byval size as integer, byref data as short).My console application startup thingy is a module. When I call this method in my main it works fine, if I call it from another method that was called by main it works as well.However, it doesn't work when I call it from my Timer_Elapsed sub? I guess this has to do something with threads but I can't figure it out.
Module Main
Private Timer As New System.Timers.Timer
Private PLC As New ACTMULTILib.ActEasyIF
Private DataSet As new DataSet
[code].....
I have a project that has some VB code in it that I'm not allowed to convert to C#. I work in C# and not very good at VB, but I am needing to modify that VB code to use some C# methods I created.
For example:
C#:
Code:
using MGCIS2.Reporting;
using CrystalDecisions.Shared;
[code]....
At this line in the VB code (Dim crv As New Tax.Reports.CrystalReportViewer(_rdbc)) it is giving me an error:Too many arguments to 'Public Sub New()'
I converted some code from c# for a VB.net project I have an object declared as this :
<Serializable()> _
Public Class oUserApplication
Public ApplicationID As Integer = 0
Public ApplicationRoleID As Integer = 0
[code]....
I am having some problems calling the First() method of the System.Collections.ObjectModel.Collection(Of T) class. My front-end web application is VB.Net 3.5, and the data access layer is C# 3.5. Here is pretty much the sample code I have:
[Code]...
I have a form call form1 which is a mdi tab. Within form1 there is a datagridview and a button. When the button is clicked it will fire a method within form1 to update and repopulate the dgv.
Now my problem now is that I have another form call form2 which I load using .showdialog. Whenever I update the data within form2, it will fire method from form1 and update the dgv in form1. However the dgv doesn't seem to repopulate the updated data.
I've got some debugging code that looks like this[code]...
The purpose of this code is to output the name of the calling method. Now, I would like to output the FILENAME where the calling method resides. Is this information available?
I am using a .dll called Kiosk in my application which is resonsible for disabling some keyboard keys. I am doing like this... using Kiosk; public static Kiosk.Kiosk KIOSK = new Kiosk.Kiosk();
[Code]...
I am maintaining some VB .net code and noticed that they call a method with a period in front of it. What does that mean?
View 1 Repliesessentially I need to create a class that houses the methods and then call the methods in the form but I can't seem to find out what the right code is to call it. I think there may be an issue with the conversion from a double to a string.
This is what I have for the Class
Public Class Aircraft
Dim Names() As String = {"A-747", "A-737", "C-150", "D-240"}
Dim TakeOffVelocity() As Double = {250, 264, 270, 240}
Dim Acceleration() As Double = {33.5, 44.2, 37.1, 51.9}
[code]...
Calling method in anonymous object?This works:
Call (New MyForm).Show
Lets say I have a application with these three items:
A startup form called form1
A class lets say Class1
A class lets say Class2
How can I access a method in class2 from within class1? For example in Class2 I have a method call AddToDatabase(sql as string) and in a method is Class1 I have a SQL statement that I want to implement.
Solution that didn't work: Initializing an instance of Class2 in form1 called myClass2 and trying to reach it using: form1.myClass2Initializing an instance of Class2 in New subrotine of Class1 and trying to call it through: myClass2
I have a question regarding how can i use a method name configurable to be called.
E.g
1.I have a xml file with three elements looking like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<element attribute1="a" attribute2="b" attribute3="Send" />
</root>
[Code]....
So after i add the values to the list, for example : element.ThirdElement() will have the value from attribute3 ("Send"). Also element.secondElement() will retain the value from attribute2 and so on.
I have a logging class that stores entries in a datatable dt. I then use SQLBULKCOPY to write that dt out to a sql table. Basic stuff. Problem is, I'd like to only call SQLBULKCOPY when there's say 50 entries in the dt. The problem is, what if I'm done (either intentionally or not, like if the code block that's using the log class throws an exception) with the logging object and there are still 15 rows in the dt?
View 1 RepliesI am writing a alternative to GDI, and rigth now i am working at a logging function. The idea is that while you use the class to draw, it will write a logg of what you have done, which can be used to draw it back later. In that way i would be able to store a drawing with weary little disk usage.
[Code]...
in vb I can do that
sub SetFocusControl(byref ctl as object)
ctl.Focus
end sub
in c# the compiler complaint that object doesn't have a Focus method
void SetFocusControl(ref object ctl)
{
ctl.Focus();
}
how can I do the same in c#?
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?
I'm working on a base class right now, here's a basic rundown of it:[code]The problem is, in the Public Class bar example, some classes may implement MyInterface, and others don't. What I'd like to be able to do is have the sub New() in the structure in the base class "Foo" be able to tell if the class calling it (either the Base class, or the child class) implements MyInterface or not.
View 8 RepliesIs it possible to prohibit an instance of a class from calling a shared/static method?
For example:
I want to allow this:
ClassName.MethodOne()
But I want to disallow this:
Dim A As New ClassName
A.MethodOne()
The reason this is desirable is that in this case it is semantically confusing if an instance can call the method.
How do you call a codebehind/class method from a gridview in an aspx page? Also, I need to pass the value of databound column to that method.
<asp:BoundField DataField="Precision" />
<asp:BoundField DataField="MyNumber" DataFormatString="FormatHelper.Format(MyNumber, Precision)" />
I have a DataGridView that is bound to a DataTable. I was using AutoGenerateColumns=true but I changed it to false so that I could manage the columns myself and then I started getting an InvalidProgramException in the event handler for DataGridView.CurrentCellDirtyStateChanged. When this event handler calls another method called CheckFilter() it throws the exception. It does not enter the method when I step through the code so the exception happens when the method is called. CheckFilter() is a private sub with no parameters. The exception message is "Common Language Runtime detected an invalid program". I am using vb.net with .net 2.0 and Visual Studio 2008 on Windows 7.
View 1 RepliesI have a treeview which i populate dynamically using an XML Datasource. The leaf nodes in the TreeView attempt to open a URL in an iframe within the page.This all works fine, but i would like the iframe to be hidden until the point the leaf node is selected.what event is triggered when the nodes are clicked?? I tried the SelectedNodeChanged event but this doesnt seem to get triggered!
UPDATE - The TreeView code is shown Below
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" DataSourceID="XmlDataSource2" AutoGenerateDataBindings="False">
<DataBindings>
[code]....
While fiddling with my code i noticed that when i remove the NavigateUrlField="URL" from my code the tree triggers the SelectedNodeChange event, But does not Trigger if NavigateUrlField="URL" is put back in.
In VB.NET, it is entirely possible to pass an integer as a string parameter to a method without calling .ToString() - it's even possible to call .ToString without the ()'s. The code will run without a problem, VB will interpret the integer as a string without having been told to. In C#, these would cause compilation errors - you are required to call .ToString() and to call it correctly in that situation before it will compile. Is there a way to make the VB compilation process check for the same things as the C# compilation process? Would it be best practice in a mixed team to force this check?
View 3 RepliesI have a .dll file (Interop.ACTMULTILib.dll) that I use to connect to a PLC. This .dll contains a sub called ReadDeviceBlock2(byval devicename as string, byval size as integer, byref data as short). When I call this method in my main it works fine, if I call it from another method that was called by main it works as well.However, it doesn't work when I call it from my Timer_Elapsed sub? I guess this has to do something with threads but I can't figure it out.
Module Main
Private Timer As New System.Timers.Timer
Private PLC As New ACTMULTILib.ActEasyIF
Private DataSet As new DataSet[code].....
I'm designing a .NET-Type at runtime by using the Reflection.Emit-Namespace. Currently, I'm about to generate a method which invokes an already existing method in the generating class:
[Code]...