Autodesk-Forge / model.derivative-csharp-context.menu

Extract properties from Revit files: Adds context menu for extracting properties for Revit files and save into an excel file
MIT License
20 stars 19 forks source link

Internal Server Error #2

Open mon-ami opened 7 years ago

mon-ami commented 7 years ago

Hello, can you please suggest me in this? I have followed the instructions properly (found the dll and run regasm successfully, too) The only thing I had to modify was setting the startup project to Translator. The program starts, Open file dialog opens, the context menu is there on my rvt file, but after selecting it I got this unhandled exception: System.Reflection.TargetInvocationException was unhandled HResult=-2146232828 Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbacks() at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Translator.Program.Main(String[] args) in C:\Users\My\work\fiverr\revit\Translator\Program.cs:line 42 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: HResult=-2146233088 Message=Error uploading file: InternalServerError Source=Translator StackTrace: at Translator.Server.<UploadFile>d__1.MoveNext() in C:\Users\My\work\Translator\Server.cs:line 53 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Translator.Progress.<Progress_Load>d__5.MoveNext() in C:\Users\My\work\Translator\Progress.cs:line 48 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state) InnerException:

augustogoncalves commented 7 years ago

Despite the error happens on the desktop app, it's actually throwing an "Internal Server Error", meaning the server is the one with problems. Are you running it locally? If so, check a breakpoint at TranslatorController.cs - UploadObject method. If is running on a host, check if you enable write access to AppData folder.

mon-ami commented 7 years ago

Thanks for answering! Yes, I'm running it locally and I think I'm getting closer. I totally missed this sentence:

For this new app, use http://localhost:3000/api/forge/callback/oauth as Callback URL, although is not used on 2-legged flow.

So I configured the web/servers property to that URL. And also set the TranslatorServer as starting project. I also configured IIS Express to enable directory listing (to avoid the problem in attachment), but now I got a list of files and directories and nothing happens. Plus, I need to create an addin to Revit from this (without the context menu, the exporting is the point), do you think I can connect these together? kep

augustogoncalves commented 7 years ago

To debug you should start the TranslatorServer, then use the right-click to launch the desktop app (this upload the .RVT, check for status and download .XLS).

It can work on a Revit plugin, just move the code from Translator.exe into your plugin, meaning it will get the file and upload it from inside Revit, just make sure the file is read-enabled.

The translator server don't require directory listing as there is nothing there, just the API endpoints.

mon-ami commented 7 years ago

OK, now I'm aware of the right workflow, but there is something with TranslatorServer at my end :( I omitted the directory listing as it is not needed, still when I start TranslatorServer, a browser opens, but with the error (dirlisting) from previous comment. When I'm debugging, it just ends after WebApiConfig' Register method (I mean the http://localhost:3000/api/forge/callback/oauth loads with error, then the debugger options are unavailable, I have to stop it manually) Many thanks for your help!

augustogoncalves commented 7 years ago

On the project settings, ensure that TranslatorServer is configurated to do not launch page on debug, there is no need. If you have a Revti plugin on the same solution as the TranslatorServer, go to solution properties and configure to start 2 projects on debug. That way you can debug it property.

mon-ami commented 7 years ago

OK, thanks, I set Start Action to "Don't open a page. Wait for....". I have no plugin code yet, I'd like to make your project work at my end first. But still, when I start the TranslatorServer it seems to run, but the context menu doesn't appear on any rvt file... So I guess the desktop app won't start. I have no clue where to put any breakpoints, because any of them seems to be hit...

augustogoncalves commented 7 years ago

the desktop app will not start manually, the context menu starts it. The context menu needs to be registered with regasm, have you perform this step? Any error?

mon-ami commented 7 years ago

I remember setting it without errors. Is it needed to set more than once? Anyway, I did it again, the result is in attachment (same as first time). Does debug or release version matter? (I registered the one in obj/Debug first, but now the Release, too) kep

mon-ami commented 7 years ago

Well, I've skipped the deployment part so far, because I thought it wasn't needed for local runs. Now I tried to follow the steps here: http://adndevblog.typepad.com/cloud_and_mobile/2017/01/deploying-forge-aspnet-samples-to-appharbor.html , but I have to admit, I have no idea of deploying such things (nor building it into a plugin, unfortunately). If you have more time to suggest me on this, I appreciate it much, otherwise I've got to get familiar with the javascript version.

augustogoncalves commented 7 years ago

I'll prepare a video explaining this sample, that might help.

Meanwhile, as you mentioned a Revit plugin, why not write it using Revit APIs? There is no need to use Forge if you have the .RVT project open on Revit. Please correct if I missed anything here.

mon-ami commented 7 years ago

No, you didn't miss anything, I'm the new and incompetent in the area right now, my idea was to convert this somehow to export the actual rvt in Revit via plugin. I don't know it yet how to achieve without this project (and the javascript version), I found those two as the only existing samples, so I thought they can be a good starting point to create the plugin.

augustogoncalves commented 7 years ago

See video demo: https://www.youtube.com/watch?v=Vu8yAhmZUb0

mon-ami commented 7 years ago

Thank you so much! I did exactly as you explained, but after starting the server, the context menu won't appear on any rvt file. I have no idea what's different on my side...

augustogoncalves commented 7 years ago

you may need to remove it and add again, just replace the /codebase with /u to unregister, then try again. On the video I'm using the Framework64 folder for Windows 64 bit, so if you have a 32 bit OS, use the Framework folder instead.