Try our conversational search powered by Generative AI!

Episerver forms error

Vote:
 

Hi,

Here is a code I copied to override Form Submiting. However when I compile my project, I get a "Error112The type or namespace name 'Forms' does not exist in the namespace 'EPiServer' (are you missing an assembly reference?)

I have installed Episerver Forms by nuget, and I checked my References and Episerver.Forms,  Episerver.Forms.Core and Episerver.Forms.UI are all there.

using System;
using System.Linq;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using EPiServer.Forms.Core.Events;
using EPiServer.Logging;
using EPiServer.Core;
using EPiServer.Forms.Core.Models;
using EPiServer;
using EPiServer.Forms.Core;

namespace AlloyDemoKit.Business.Forms
{
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class FormEventsInitialization : IInitializableModule
{
private static readonly ILogger _logger = LogManager.GetLogger();

public void Initialize(InitializationEngine context)
{
var formsEvents = ServiceLocator.Current.GetInstance();
formsEvents.FormsSubmissionFinalized += FormsEvents_FormsSubmissionFinalized;
}

private void FormsEvents_FormsSubmissionFinalized(object sender, FormsEventArgs e)
{
if (!string.IsNullOrEmpty(e.FormsContent.Name))
{
var loader = ServiceLocator.Current.GetInstance();
FormsSubmittedEventArgs submitArgs = e as FormsSubmittedEventArgs;
string msg = string.Format("Form {0} completed at {1}\tSubmission id: {2}",
e.FormsContent.Name,
DateTime.Now,
submitArgs.SubmissionData.Id);
_logger.Information(msg);

var formElements = submitArgs.FormsContent.Property["ElementsArea"].Value as ContentArea;

foreach (var item in submitArgs.SubmissionData.Data)
{
if (item.Key.StartsWith("SYSTEM"))
{
_logger.Information(item.Key + ": " + item.Value);
}
else
{
int id = Convert.ToInt32(item.Key.Substring(item.Key.LastIndexOf("_") + 1));
var elementId = formElements.Items.Where(i => i.ContentLink.ID == id).FirstOrDefault();
ElementBlockBase element = loader.Get(elementId.ContentLink) as ElementBlockBase;
string friendlyName = element != null ? element.GetElementInfo().FriendlyName : item.Key;
_logger.Information(friendlyName + ": " + item.Value);
}
}


}
}


public void Preload(string[] parameters) { }

public void Uninitialize(InitializationEngine context)
{
var formsEvents = ServiceLocator.Current.GetInstance();
formsEvents.FormsSubmissionFinalized -= FormsEvents_FormsSubmissionFinalized; ;

}
}
}

#151822
Aug 08, 2016 10:18
Vote:
 

found the solution, need to install at least .net 4.5.2 framework. didn't see this solution anywhere else or as a system requirment when installing episerver forms... :(

#151833
Edited, Aug 08, 2016 14:26
Vote:
 

I also had this issue, but changing to .NEt 4.5.2 did the trick! 

#154802
Aug 30, 2016 11:20
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.