Friday, March 16, 2012

please help this one is simple

I have some code stored in a file called functions.vb I want to be able to call methods in this class from anywhere in the project, for example functions.GetCookie("member_id").

I know how to do it if i compile it, make it a dll file and make it a reference, bu I do not want to do this because i want to beable to edit the code at anytime for some reason i cannot figure out how to accompish this. Seems like it should be very simple?Make a public class named "functions" and all of the methods you want to call "Shared", then include the functions.vb file in the project you want to call them from.

This will allow you call any shared method using the class name . method name from any place in the project.
right now i have functions in a . dll file and i am able to at the top of my code write:

Imports CoreFile.functions

and be able to call methods of the functions class without typing:
CoreFile.functions.GetCookie()

I can just simpley type GetCookie() it seems to me that the Import statement at the top of the code only works with references. is there a way around this? am i doing somthing wrong?

I want to be able to import my functions.vb class

Thanks.
it IS really simple:

if you want to be able to modify your code behind at any time and not have it as a dll then all you need to do is include this at the top of your aspx page:


<%@. Page Inherits="myCodeBehind" src="http://pics.10026.com/?src=myCodeBehind.vb" %>

with this line at the top of your aspx page, you can access any of the functions in your vb file without having it in dll form. just remember to change myCodeBehind.vb to whateveer your codebind.vb page is called.
If you change GetCookie() or any other function inside your functions.vb class you have to re-compile the class and re-compile your application referencing that class (if you want it to access the newly modified functions).

I keep two copies of visual studio open at all times. One has my web application and the other has my functions. Recompile functions, recompile app and now app can access any new functions and the modified functions.

If you think about "how" it works it makes sense. My app references "functions.vb" which is compiled into a DLL and copied into my apps folder. When I re-compile "functions.vb" the newly compiled DLL is still located in it's own base folder. It's not until I re-compile my app that it brings over the new copy of the DLL.
yes that works for a .aspx page but what if i am calling the method from other classes as described above. I can write "Imports CoreFile.functions " at the top of the class
this allows me to call methods of my functions class without writing CoreFile.functions.GetCookie(). Instead I can just write GetCookie() and it recognizes it as CoreFile.functions.GetCookie() is there a way to import a file that is not in references. I want to be able to do something to the effect of "Imports functions.vb" right now it is set as "Imports CoreFile.functions " where CoreFile is a dll defined in references.

0 comments:

Post a Comment