WPF-Pilot / WpfPilot

https://wpfpilot.dev
Other
10 stars 5 forks source link

Unable to attach to process #4

Closed rperneel closed 6 months ago

rperneel commented 6 months ago

Hello,

I am trying to attach to our application (Click once WPF app) and am getting the following:

System.AggregateException : One or more errors occurred. (System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at WpfPilot.Injector.Injector.InjectAppDriver(WpfProcess process, String pipeName, String dllRootDirectory) in C:\code\WpfPilot\WpfPilot.Injector\Injector.cs:line 80
   at WpfPilot.Injector.Program.Main(String[] args) in C:\code\WpfPilot\WpfPilot.Injector\Program.cs:line 29

by using

using var appDriver = AppDriver.AttachTo(29620);

I have tried to connect to our deployed application, and running the app in debug locally.

Have confirmed that I am able to attach to other applications (non-click once) and was able to interact with the app. I also use snoop on the application with no issue. Thoughts?

(also this is an awesome concept! I looked into doing this, but ran out of time, so if I can get this working, this would be a life saver!)

ELanning commented 6 months ago

Is the application available to the public? I'd love to take a look and see what's going on. If it's not, I'll try building a ClickOnce WPF application and see if I can repro.

That error message makes me think it is injecting but a DLL is not being loaded correctly once it is, but that is just a shot in the dark.

Is this dot net 8.0+ or?

rperneel commented 6 months ago

it is not public. I just tried the telerik sample apps (https://www.telerik.com/wpf/sample-applications) and it was able to inject (just timed out trying to find my element.

Is this dot net 8.0+ ...

do you mean the application we are trying to test? or the unit test library?

ELanning commented 6 months ago

do you mean the application we are trying to test? or the unit test library?

Well, it wouldn't hurt to know both, but I was talking about the application.

Also curious if your app uses Newtonsoft.Json and if so, which version?

rperneel commented 6 months ago

<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>

test lib is net8

Newtonsoft.Json -> 13.0.1

ELanning commented 6 months ago

Ah, the test lib and the app framework must match. This is because otherwise it can result in cross communication serialization errors. I originally had a check for mismatches, but it was unfortunately buggy, so it got cut before the first release.

I'm guessing the issue is the test lib, which is net8, is trying to inject net8 dlls into the app, which is framework v4.6.2.

Setting up a new test project with a v4.6.2. net framework target might fix your issue.

I'll create an action item on adding a check for this, so more people don't run into it.

rperneel commented 6 months ago

interesting. gives me something to go on. Thanks!

ELanning commented 6 months ago

Feel free to re-open the issue if that doesn't solve your problem. Thanks for the report.