eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. ๐—น๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—ถ๐—ป.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ, ๐˜†๐—ผ๐˜‚๐˜๐˜‚๐—ฏ๐—ฒ.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ and ๐˜๐˜„๐—ถ๐˜๐˜๐—ฒ๐—ฟ @๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ and or simply ๐—ฆ๐˜๐—ฎ๐—ฟ/๐˜„๐—ฎ๐˜๐—ฐ๐—ต this repository and get notified from ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ
http://expand.expandframework.com
Microsoft Public License
220 stars 114 forks source link

Model Editor Broken Due to eXpand Import Module #649

Closed DSCmattb closed 4 years ago

DSCmattb commented 4 years ago

Describe the bug Opening the Model Editor with the ImportWizard included throws the following errors:

Unable to create an instance of the "EMS.Win.EMSWindowsFormsApplication" type.
Reason: "The type initializer for 'Xpand.Persistent.Base.General.XpandModuleBase' threw an exception."

at DevExpress.ExpressApp.Utils.Reflection.TypeData.CreateInstance(Object[] args)
   at DevExpress.Persistent.Base.ReflectionHelper.CreateObject(Type objectType, Object[] args)
   at DevExpress.ExpressApp.Design.ModelEditor.ModelLoader.LoadModel(ITypeDiscoveryService typeDiscoveryService, ITypeResolutionService typeResolutionService, String targetDiffFileName, IDisposable& obj)
   at DevExpress.ExpressApp.Design.ModelEditor.EditorPane.CreateModelEditorController()
   at DevExpress.ExpressApp.Design.ModelEditor.EditorPane.ReInit()
----------InnerException----------
The type initializer for 'Xpand.Persistent.Base.General.XpandModuleBase' threw an exception.
----------StackTrace----------
   at Xpand.Persistent.Base.General.XpandModuleBase..ctor()
   at Xpand.ExpressApp.ImportWizard.ImportWizardModule..ctor()
   at EMS.Win.EMSWindowsFormsApplication.InitializeComponent() in C:\Git_Projects\EMS\EMS.Win\WinApplication.Designer.cs:line 50
   at EMS.Win.EMSWindowsFormsApplication..ctor() in C:\Git_Projects\EMS\EMS.Win\WinApplication.cs:line 65
   at Create_EMSWindowsFormsApplication()
   at DevExpress.ExpressApp.Utils.Reflection.TypeData.CreateInstance(Object[] args)
----------InnerException----------
Access to the path 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\common7\ide\netstandard.dll' is denied.
----------StackTrace----------
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Xpand.Utils.Helpers.StreamExtensions.SaveToFile(Stream stream, String filePath)
   at Xpand.Persistent.Base.General.XpandModuleBase..cctor()

When I go to that folder I do not see the path specified for netstandard.dll.

From my understanding it was included in .net core 2+ which I have all versions from 2-3 installed in both x64 and x86.

Desktop (please complete the following information): Win 10 1903 Visual Studio 2019 .Net 4.6.2

apobekiaris commented 4 years ago

try running VS as Admin

DSC-ConnorW commented 4 years ago

Confirmed running as administrator solved fault, cheers.

sheldmandu commented 4 years ago

Hi @apobekiaris I'm having the same issue. Are you able to provide some info on why this occurs. It's pretty out there to require VS to be run as Admin to get things working. This isn't a requirement when working with XAF generally so don't really understand why this should necessary for expand.

apobekiaris commented 4 years ago

ModelMapper uses reflection to load dependencies as they are not known at compiletime. The VS ME has issues to understand the actuall location of the assemblies. Threfore we use the Xpand.VSIX to copy the assemblies a special folder on each build as per

https://github.com/eXpandFramework/eXpand/blob/f916916dcf045b5317c48a8d7740fdc169f86fe4/Xpand.Plugins/Xpand.VSIX/Services/ModelMapperService.cs#L38-L56

the folder contents take priority and VS ME works as usual. You could parametrize it further I guess by explicilty setting permission to this folder so admin elavation is not required, however it is not a priority task. If you think you want to do it PR are acceptable.

sheldmandu commented 4 years ago

Thanks @apobekiaris that helps explain it. Is there any way to avoid it or just gotta run VS with elevated to admin. I presume that's why you need VSIX also.

apobekiaris commented 4 years ago

I posted the related code above, it is not parametirized as discussed previously

expand commented 4 years ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.