Fiddler version:
Progress Telerik Fiddler Web Debugger v5.0.20182.28034 for .NET 4.6.1
Built: 2018年6月27日
1: First, we use vs2017 to create a new .NET 4.0 library project (This is wrong, as I will say below, you need to build a 4.6.1 project, otherwise the compilation will fail), as shown below:
Since my fiddler version is relatively high, the requirements for the .NET version will be higher, and the error will be reported as follows when compiling and generating the .NET 4.0 version:
1>------ All rebuild has been started: Project: fiddler-plugin-demo, Configuration: Debug Any CPU ------ 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3274: Failed to resolve the main reference "Fiddler" because it was targeted at ". NETFramework, Version=v4.6.1". This framework version is higher than the current target framework". NETFramework,Version=v4.0”。 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3268: Failed to resolve the main reference "Fiddler", Because it has an indirect dependency on the framework assembly "System.Net.Http, version=4.0.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", which fails to be parsed in the current target framework. “. NETFramework,Version=v4.0”。 To resolve this issue, remove the reference to "Fiddler" or redirect the target of the application to the framework version that contains "System.Net.Http, version=4.0.0.0, culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly analytics, version=1.0.20182.27266, culture=neutral, PublicKeyToken=2b2cea67609c9510 "has indirect dependencies, and the assembly is directed at ". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly newtonsoft.json, version=11.0.0.0, culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"has indirect dependencies, and the assembly is directed against ". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: Failed to resolve the main reference "Fiddler" because it had a problem with assembly GA. analytics.monitor, version=1.0.20182.27266, culture=neutral, PublicKeyToken=2b2cea67609c9510 "has an indirect dependency that the assembly is related to". NETFramework, Version=v4.5" framework. This framework version is higher than the current target framework". NETFramework,Version=v4.0”。 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\Properties\AssemblyInfo.cs(37,12,37,19): error CS0246: Failed to find type or namespace name" Fiddler" (is there a missing using instruction or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(1,7,1,14): error CS0246: Failed to find type or namespace name "Fiddler" (missing using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(10,34,10,45): error CS0246: Failed to find type or namespace name "IAutoTamper" ( Is there a missing using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(19,44,19,51): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(24,45,24,52): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(29,45,29,52): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(34,46,34,53): error CS0246: Failed to find type or namespace name "Session" (missing.) using directive or assembly reference?) 1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\DemoExtention.cs(39,44,39,51): error CS0246: Failed to find type or namespace name "Session" (missing using directive or assembly reference?) ========== Regenerate all: 0 succeeds, 1 fails, and 0 ========== skipped
The solution is to change to .NET 4.6.1!
2: Add the fiddler.exe reference in Solution Explorer, my fiddler installation directory is: C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler, as shown below:
3: Set the minimum version of fiddler that the plugin is running
Add the Fiddler.RequiredVersion attribute to your project's AssemblyInfo.cs (and anywhere else in your code) file.
4: Create a new Fiddler tab UI control
You need to add a reference to the System.Windows.Forms assembly
Start by adding a user control to your project named TestControl.cs (arbitrary), as shown in the image below:
Then place a random Button control on top of the user control and write a simple line of click event code:
5: Create a new DemoExtention extension class
DemoExtention class inherits the IAutoTamper interface,The IAutoTamper interface inherits the IFiddlerExtension interfaceAll plugins that implement the IAutoTamper interface will be called on every http/https request or response, so they can be used to hijack or modify http/https request response data.
Note: The method of this interface is called in the background, non-UI thread, if you want to update the UI, you can use the Invoke or BeginInvoke method to update the UI. All methods of IAutoTamper may be executed before the OnLoad event.
The code is as follows:
6: Fiddler loads the plugin
After we program and generate, copy the two files fiddler-plugin-demo.dll and fiddler-plugin-demo.pdb under the Debug directory to the scrip{filter}ts folder of our fiddler installation directory.
My own is: C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler\scrip{filter}ts folder
Finally, we restart and open Fiddler, and we can see our controls on the tab, as shown below:
7: Enable the plugin to be automatically deployed to the fiddler plugin directory
Every time we modify the plugin, we need to copy the dll to the scrip{filter}ts folder again, we can solve this problem by the VS generation event, we recompile the generation, VS will automatically copy our dll to the scrip{filter}ts directory, and fill in the following command in the later generation event command line:
As shown below:
Tested for normal use.
Finally, attach the source code:
Tourists, if you want to see the hidden content of this post, please Reply
|