Jump to content
Tuts 4 You

How to fix a .NET application?


Recommended Posts

Hello everyone I hope someone can help me.

I'm using Mono.Cecil.dll to edit the name of the Namespaces/Classes/Functions. Everything is alright but when I save it and then I run it it shows an error of Windows that leaves to work.


Here is my code:

Dim assembly As AssemblyDefinition
assembly = AssemblyFactory.GetAssembly("The path of the .NET file")
Dim definition3 As TypeDefinition
For Each definition3 In assembly.MainModule.Types
AssemblyFactory.SaveAssembly(assembly, Application.StartupPath & "\App1.exe")

And for the "EditType" function:

Private Sub EditType(ByVal type As TypeDefinition)
If ((((type.Name <> "<Module>") AndAlso Not type.IsRuntimeSpecialName) AndAlso (Not type.IsSpecialName AndAlso Not type.Name.Contains("Resources"))) AndAlso ((Not type.Name.StartsWith("<") AndAlso Not type.Name.Contains("__")))) Then
Dim fullName As String = type.FullName
type.Name = "Here random strings"
Dim definition2 As ModuleDefinition
For Each definition2 In assembly.Modules
Dim reference As TypeReference
For Each reference In definition2.TypeReferences
If (reference.FullName = fullName) Then
reference.Name = type.Name
End If
End If
End Sub

The code is well but I searched to fix this problem of the "App leave to work" message but I didn't find nothing :(


Thanks a lot! :D

Link to comment

Why don't you use

- AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(@"c:\full\path\to\original.exe");

- assembly.Write(@"c:\full\path\to\edited.exe"); ?

And if you get an error, why don't you debug it rather than compiling then running ?

Link to comment

@mArTi This option it's for a newer version of Mono.Cecil.dll and i'm using an old version because I need some utilities from it. :)

Thanks for replying!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...