8 Replies - 5482 Views - Last Post: 27 December 2012 - 02:54 PM Rate Topic: -----

#1 Zabel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-December 12

Possible to invoke text?

Posted 26 December 2012 - 04:38 PM

Hi, I have come across a little problem. I am attempting to create a log in system for a college course I have taken. It requires you to make a secure log in system.

What I am trying to do is invoke text as code. Here is an example:

    Public Uri As [String] = New Net.WebClient().DownloadString("https://www.website.com/Method.txt")
    Public T As Type
    Public M As Reflection.MethodInfo
    Public O As New Object
    Sub Main()
        T.GetMethod("Login.CS").Invoke(Uri, Nothing)
    End Sub
End Module


Inside the Uri String will be:

Namespace Login
    Class CS
        Public Sub MyMethod()
            Windows.Forms.MessageBox.Show("This is showing an executing snippet of code!")
            Console.WriteLine("This is working perfectly!")
            IO.File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\Updated.exe", "Null")
            Console.ReadLine()
        End Sub
    End Class
End Namespace


I tried messing around with the reflection namespace and couldn't find anything that actually works. I need to invoke it directly into memory, so I cannot use CodeDOM because it generates another file. If I write Console.WriteLine("text") it should execute it.

I been trying to look for a method for days now that can actually do this. Reflection was my best bet but I did not find anything or probably didn't use it correctly to achieve this. Can anyone point me in the right direction?

Is This A Good Question/Topic? 0
  • +

Replies To: Possible to invoke text?

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,011
  • Joined: 02-July 08

Re: Possible to invoke text?

Posted 26 December 2012 - 07:50 PM

I am not sure why you are needing reflection for this. You don't need escape characters for a string type - Public Uri As String - which is a field and should be private - public members should be a Property as a standard for coding.
Was This Post Helpful? 0
  • +
  • -

#3 Zabel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-December 12

Re: Possible to invoke text?

Posted 27 December 2012 - 01:01 PM

View Post_HAWK_, on 26 December 2012 - 07:50 PM, said:

I am not sure why you are needing reflection for this. You don't need escape characters for a string type - Public Uri As String - which is a field and should be private - public members should be a Property as a standard for coding.


This is a big project, I just took out a snip of it to give an example. Sorry for that. I only ever worked with invoking methods from libraries using reflection, so I thought I may have needed it. Your post did not help me at all with moving forward or finding a solution.
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,011
  • Joined: 02-July 08

Re: Possible to invoke text?

Posted 27 December 2012 - 02:14 PM

It's not our job to fix your solutions. We tend to be helpful if we know what your up to - yours it to vague. You don't have to use reflection to access public members of other classes - create a new instance and use the properties at will.
Was This Post Helpful? 1
  • +
  • -

#5 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 218
  • View blog
  • Posts: 1,004
  • Joined: 25-June 12

Re: Possible to invoke text?

Posted 27 December 2012 - 02:24 PM

View PostZabel, on 27 December 2012 - 01:01 PM, said:

View Post_HAWK_, on 26 December 2012 - 07:50 PM, said:

I am not sure why you are needing reflection for this. You don't need escape characters for a string type - Public Uri As String - which is a field and should be private - public members should be a Property as a standard for coding.

Your post did not help me at all with moving forward or finding a solution.


You will get more help by using words such as "I don't believe your solution will work for my issue, do you have any other ideas?" or "Could you elaborate more? I'm not sure I understand your idea fully." than you ever will by blatantly pointing someone out as giving you an idea that you believe will not work.

Whether you meant the words to carry the tone of condescension that they do on purpose, or not, as they say: More flies with Honey.

The people on here are volunteers that are kind enough to take time out of their day to assist people and share their individual knowledge. Treat them right, and you will probably find the answers you seek.
Was This Post Helpful? 3
  • +
  • -

#6 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Possible to invoke text?

Posted 27 December 2012 - 02:35 PM

Yeah _HAWK_! No paycheck for you this month!
Was This Post Helpful? 1
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,011
  • Joined: 02-July 08

Re: Possible to invoke text?

Posted 27 December 2012 - 02:45 PM

Not again! =(
Was This Post Helpful? 0
  • +
  • -

#8 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Possible to invoke text?

Posted 27 December 2012 - 02:52 PM

Yes! Again and again, until you come to your senses! (at approximately 1:20)

This post has been edited by lucky3: 27 December 2012 - 02:55 PM

Was This Post Helpful? 0
  • +
  • -

#9 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 218
  • View blog
  • Posts: 1,004
  • Joined: 25-June 12

Re: Possible to invoke text?

Posted 27 December 2012 - 02:54 PM

If there is a position opening up... ^^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1