cancel
Showing results for 
Search instead for 
Did you mean: 

"Failed to create form. Please check the form attributes." error when loading a form from a class library.

Former Member
0 Kudos

hello all, we are facing a problem including some b1s forms inside class libraries.

we are developing 2 different addins, both of which include the same user defined form.

in a normal development environment we would simply create a class library with the user defined form to be shared between projects, then add a reference to this library in both addins and go for it.

too bad nothing is working, every time we try to open the form we face the dreadful "Failed to create form. Please check the form attributes." error.

obviously we are missing something, i just cannot believe it's not possibile to include user defined forms in a library.

by the way here are the details:
- vs2012 ide, c# language, fw4.5, sdk sap b1 9.1 (SAPBusinessOneSDK.dll)

- addin project and class library x86

i built a sample to show the error, there is only one form in the addin solution with a button that opens a b1f form included in the referenced class library

we're always facing this error.

now i'm conscious that there's something wrong in the generated b1s file, as it is missing in the VSIcreated section the class library form, but even if i add it i just can't instance the form



<?xml version="1.0" encoding="utf-16" standalone="yes"?>

<projects>

  <project name="{b4ea8f89-3a15-482a-add0-aef8f6cfd572}" type="Add-on">

    <file name="Form1.b1f" type="UserForm" time="18/04/2016 12:32:41">

      <content desc="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;yes&quot;?&gt;&lt;form Top=&quot;10&quot; Left=&quot;10&quot; Width=&quot;300&quot; Height=&quot;300&quot; AutoManaged=&quot;False&quot; DefaultButton=&quot;&quot; FormType=&quot;-1&quot; BorderStyle=&quot;0&quot; Color=&quot;0&quot; Pane=&quot;1&quot; Mode=&quot;1&quot; ObjectType=&quot;&quot; Client_Height=&quot;&quot; Client_Width=&quot;&quot; Settings_GridItemUID=&quot;&quot; Enabled=&quot;False&quot; EnableRowFormat=&quot;False&quot; BrowseBy=&quot;&quot; Title=&quot;New Form 1&quot; Visible=&quot;False&quot; UniqueID=&quot;&quot;&gt;&lt;datasources /&gt;&lt;item Top=&quot;25&quot; Left=&quot;22&quot; Width=&quot;252&quot; Height=&quot;181&quot; AffectsFormMode=&quot;True&quot; Description=&quot;&quot; DisplayDesc=&quot;False&quot; Enabled=&quot;True&quot; FromPane=&quot;0&quot; ToPane=&quot;0&quot; LinkTo=&quot;&quot; RightJustified=&quot;False&quot; Type=&quot;4&quot; Visible=&quot;True&quot; UniqueID=&quot;Item_0&quot; IsAutoGenerated=&quot;False&quot;&gt;&lt;specific Caption=&quot;Open a form in another library&quot; /&gt;&lt;/item&gt;&lt;FormCategory type=&quot;UserForm&quot; /&gt;&lt;/form&gt;" />

    </file>

  </project>

  <project name="{b1de0e88-7aed-4c0d-b63b-fc2c7f456e67}" type="Add-on">

    <file name="Forms/FormInLibrary.b1f" type="UserForm" time="18/04/2016 10:58:13">

      <content desc="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;yes&quot;?&gt;&lt;form Top=&quot;10&quot; Left=&quot;10&quot; Width=&quot;300&quot; Height=&quot;300&quot; AutoManaged=&quot;False&quot; DefaultButton=&quot;&quot; FormType=&quot;-1&quot; BorderStyle=&quot;0&quot; Color=&quot;0&quot; Pane=&quot;1&quot; Mode=&quot;1&quot; ObjectType=&quot;&quot; Client_Height=&quot;&quot; Client_Width=&quot;&quot; Settings_GridItemUID=&quot;&quot; Enabled=&quot;False&quot; EnableRowFormat=&quot;False&quot; BrowseBy=&quot;&quot; Title=&quot;New Form 1&quot; Visible=&quot;False&quot; UniqueID=&quot;&quot;&gt;&lt;datasources /&gt;&lt;item CellHeight=&quot;16&quot; TabOrder=&quot;0&quot; TitleHeight=&quot;20&quot; Top=&quot;26&quot; Left=&quot;21&quot; Width=&quot;150&quot; Height=&quot;150&quot; AffectsFormMode=&quot;True&quot; Description=&quot;&quot; DisplayDesc=&quot;False&quot; Enabled=&quot;True&quot; FromPane=&quot;0&quot; ToPane=&quot;0&quot; LinkTo=&quot;&quot; RightJustified=&quot;False&quot; Type=&quot;127&quot; Visible=&quot;True&quot; UniqueID=&quot;Item_0&quot; IsAutoGenerated=&quot;False&quot;&gt;&lt;specific MatrixLayout=&quot;0&quot; SelectionMode=&quot;0&quot; /&gt;&lt;Column BackColor=&quot;16777215&quot; ChooseFromListAlias=&quot;&quot; ChooseFromListIsAutoFill=&quot;False&quot; ChooseFromListUID=&quot;&quot; FontSize=&quot;-1&quot; ForeColor=&quot;-1&quot; TextStyle=&quot;0&quot; DisplayDesc=&quot;False&quot; Visible=&quot;True&quot; AffectsFormMode=&quot;True&quot; ValOn=&quot;Y&quot; IsAutoGenerated=&quot;False&quot; ValOff=&quot;N&quot; Description=&quot;&quot; Title=&quot;#&quot; Width=&quot;25&quot; Editable=&quot;True&quot; Type=&quot;16&quot; RightJustified=&quot;False&quot; UniqueID=&quot;#&quot; Sortable=&quot;False&quot;&gt;&lt;databind DataSource=&quot;&quot; Databound=&quot;False&quot; TableName=&quot;&quot; Alias=&quot;&quot; /&gt;&lt;/Column&gt;&lt;Column BackColor=&quot;-1&quot; ChooseFromListAlias=&quot;&quot; ChooseFromListIsAutoFill=&quot;False&quot; ChooseFromListUID=&quot;&quot; FontSize=&quot;-1&quot; ForeColor=&quot;-1&quot; TextStyle=&quot;0&quot; DisplayDesc=&quot;False&quot; Visible=&quot;True&quot; AffectsFormMode=&quot;True&quot; ValOn=&quot;Y&quot; IsAutoGenerated=&quot;False&quot; ValOff=&quot;N&quot; Description=&quot;&quot; Title=&quot;Col_0&quot; Width=&quot;50&quot; Editable=&quot;True&quot; Type=&quot;16&quot; RightJustified=&quot;False&quot; UniqueID=&quot;Col_0&quot; Sortable=&quot;False&quot;&gt;&lt;databind DataSource=&quot;&quot; Databound=&quot;False&quot; TableName=&quot;&quot; Alias=&quot;&quot; /&gt;&lt;/Column&gt;&lt;/item&gt;&lt;item Top=&quot;230&quot; Left=&quot;26&quot; Width=&quot;65&quot; Height=&quot;20&quot; AffectsFormMode=&quot;True&quot; Description=&quot;&quot; DisplayDesc=&quot;False&quot; Enabled=&quot;True&quot; FromPane=&quot;0&quot; ToPane=&quot;0&quot; LinkTo=&quot;&quot; RightJustified=&quot;False&quot; Type=&quot;4&quot; Visible=&quot;True&quot; UniqueID=&quot;Item_1&quot; IsAutoGenerated=&quot;False&quot;&gt;&lt;specific Caption=&quot;Button1&quot; /&gt;&lt;/item&gt;&lt;item Top=&quot;230&quot; Left=&quot;94&quot; Width=&quot;65&quot; Height=&quot;20&quot; AffectsFormMode=&quot;True&quot; Description=&quot;&quot; DisplayDesc=&quot;False&quot; Enabled=&quot;True&quot; FromPane=&quot;0&quot; ToPane=&quot;0&quot; LinkTo=&quot;&quot; RightJustified=&quot;False&quot; Type=&quot;4&quot; Visible=&quot;True&quot; UniqueID=&quot;Item_2&quot; IsAutoGenerated=&quot;False&quot;&gt;&lt;specific Caption=&quot;Button2&quot; /&gt;&lt;/item&gt;&lt;FormCategory type=&quot;UserForm&quot; /&gt;&lt;/form&gt;" />

    </file>

  </project>

  <project name="VSIcreated" type="VSIBuilt">

    <file name="Form1.b1f" type="UserForm">

      <content desc="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;&lt;Application&gt;&lt;forms&gt;&lt;action type=&quot;add&quot;&gt;&lt;form appformnumber=&quot;-1&quot; FormType=&quot;-1&quot; type=&quot;0&quot; BorderStyle=&quot;0&quot; uid=&quot;&quot; title=&quot;New Form 1&quot; visible=&quot;0&quot; default_button=&quot;&quot; pane=&quot;1&quot; color=&quot;0&quot; left=&quot;10&quot; top=&quot;10&quot; width=&quot;300&quot; height=&quot;300&quot; client_width=&quot;&quot; client_height=&quot;&quot; AutoManaged=&quot;0&quot; SupportedModes=&quot;15&quot; ObjectType=&quot;&quot; mode=&quot;1&quot;&gt;&lt;datasources&gt;&lt;DataTables /&gt;&lt;dbdatasources&gt;&lt;action type=&quot;add&quot; /&gt;&lt;/dbdatasources&gt;&lt;userdatasources&gt;&lt;action type=&quot;add&quot; /&gt;&lt;/userdatasources&gt;&lt;/datasources&gt;&lt;Menus /&gt;&lt;items&gt;&lt;action type=&quot;add&quot;&gt;&lt;item top=&quot;25&quot; left=&quot;22&quot; width=&quot;252&quot; height=&quot;181&quot; AffectsFormMode=&quot;1&quot; description=&quot;&quot; disp_desc=&quot;0&quot; enabled=&quot;1&quot; from_pane=&quot;0&quot; to_pane=&quot;0&quot; linkto=&quot;&quot; right_just=&quot;0&quot; type=&quot;4&quot; visible=&quot;1&quot; uid=&quot;Item_0&quot; IsAutoGenerated=&quot;0&quot;&gt;&lt;specific caption=&quot;Open a form in another library&quot; /&gt;&lt;/item&gt;&lt;/action&gt;&lt;/items&gt;&lt;ChooseFromListCollection&gt;&lt;action type=&quot;add&quot;&gt;&lt;ChooseFromList UniqueID=&quot;-1&quot; ObjectType=&quot;-1&quot; MultiSelection=&quot;0&quot; IsSystem=&quot;1&quot; /&gt;&lt;/action&gt;&lt;/ChooseFromListCollection&gt;&lt;DataBrowser BrowseBy=&quot;&quot; /&gt;&lt;Settings MatrixUID=&quot;&quot; Enabled=&quot;0&quot; EnableRowFormat=&quot;0&quot; /&gt;&lt;/form&gt;&lt;/action&gt;&lt;/forms&gt;&lt;/Application&gt;" />

    </file>

  </project>

</projects>




Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Christian,

I have never use the B1S project, so I could not answer your question here.

But, I built my own framework and call the form XML file directly using the good old LoadBacthActions method.

The file is included in my project as an embedded resource.

This way i free myself of the dependency on the B1s file which is outside of our control.

I believe this can be your work around if you can not find any solution for your current problem.

Regards

Edy

Former Member
0 Kudos

thank you edy, but obviously we wanted to avoid to roll back to the good old known methods

this solution will be our last resort..

maik_delly
Active Contributor
0 Kudos

Hi Christian,

I have to agree with Edy.

B1 Studio is a nice tool to create forms ( in comparison to ScreenPainter ), in addition eventhandling is much more intuitive and simple. But in general it has a lot of flaws that are just plain annoying.

For customizing your SBO inhouse or creating "simple" addons it is very handy though.

I also tried your approach to put forms in a class library - without success ( but maybe it is possible ).

I think the best way would be to combine "new" and "old" way like that :

1. Create user defined form with the help of B1 Studio

2. Export as *.srf  ( this xml you can have in a library )

3. LoadBacthActions

Even for the form events you can have the eventhandler in your library - this is of course the work you want to avoid but if you use one class file per form imho it is not so bad ( one time work to create a template ).

regards,

Maik

Answers (1)

Answers (1)

Former Member
0 Kudos

the problem is in the constructor as it just can't serialize back the content of the b1s..

this is the exception detail:




System.Exception was caught

  HResult=-2146233088

  Message=Failed to create form. Please check the form attributes.

  Source=SAPBusinessOneSDK

  StackTrace:

       at SAPbouiCOM.Framework.UserFormBase..ctor()

       at FormsLibrary.Forms.FormInLibrary..ctor() in c:\Users\user\Documents\Visual Studio 2012\Projects\TEST FORM IN LIBS\FormsLibrary\Forms\FormInLibrary.b1f.cs:line 12

       at TestAddin.Form1.Button0_ClickBefore(Object sboObject, SBOItemEventArg pVal, Boolean& BubbleEvent)

  InnerException:


any hint is appreciated, thans in advance.


how do you share forms between addins if not using a class library?


Former Member
0 Kudos

bump!