A few things you may want to check:
Is the TBB reliant on some/certain content being published to Publishing Target?
Is your Publisher scaled out from you CM? If so, then it may be that there's an extension/customisation that has not been installed on the Publisher.
Have you made changes to the Compound Template or TBB? If so, then you'll need to make sure ...
If I remember correctly, the XO TBBs aren’t created using Template Builder. Instead, they are created when XO is installed as a feature.
By default, the XO TBBs are created (by the installer) in /Building Blocks/Default Templates/Experience Optimization
To summarize the issue and fix:
The default [Publication]\Building Blocks\Default Templates\Tridion.SiteEdit.Templating (TBB) C# Assembly Template broken.
It seems that the template builder upgrade process does not upgrade the Tridion.SiteEdit.Templating TBB (DLL) - this is needed for the XPM tags to be rendered for both CT and PT. To manually fix this ...
The installer adds the TBBs to the "default templates" configuration -- which is what is used when you choose "Create Default Building Blocks" in Template Builder. So yes, you need to have XO installed first -- and then you would need to run Template Builder to add the TBBs to a given installation.
It's important to note is that the "Create Default Building ...
publishContext.PublicationTarget.Title; is not working with razor , you can use Engine.PublishingContext.TargetType and see if you can get the target , if not create a .net Code and use it on your Component Template
refer to this link for mofre details.
Images do not have a URL until they are published, as mentioned by @Nuno.
In your code you'll need to publish the binaries to get a URL you can use either the AddBinary or the PublishBinary method to publish binaries. I'd recommend AddBinary, as shown below:
ItemFields metadataFields = new ItemFields(objSG.Metadata, objSG.MetadataSchema);
The final solution which solved this issue permanently was to change the razor mediator helper functions TBB into a .txt file. Loading the TBB multiple times in the same template was causing the issue in XPM due to the way in which the Razor Mediator reads the file. Changing the helper functions over to a .txt file and importing that instead, fixed the ...
Definitely consider using DXA 2.0 (or higher).
It provides what you are asking for and, in general it provides a kick-start foundation for such “Dynamic Delivery” implementations.
Note that DXA is an evolution of DD4T which is supported by SDL. DD4T is still around, but mainly for existing implementations; for new implementations I would recommend DXA.
Here are some answers to your questions. Hopefully they help to clarify things:
Q1. What is the best approach for publishing to the Broker database
A1. Whether items are stored in the Broker database or on the web server’s filesystem (or elsewhere!) is normally determined by the configuration in the Deployer’s cd_storage_conf.xml file, rather than by the ...
It would really help if you edit your question and provide some more details about what you are exactly doing in your C# TBB.
But gathering from the stack trace your GenerateMegaMenuXml TBB is indeed failing in its Transform method.
You mention in a comment on @Jonathan's answer that all the TBB does is append a few nodes to the XML in the Output item of ...
The project files of the latest DD4T Templates release (https://github.com/dd4t/DD4T.TridionTemplates/blob/master/source/DD4T.Templates/DD4T.Templates.csproj and https://github.com/dd4t/DD4T.TridionTemplates/blob/master/source/DD4T.Templates.Base/DD4T.Templates.Base.csproj) show us the following dependencies from SDL Tridion 2013 SP1:
In January 2008 Tridion R5.3 was released, bringing us the Modular Templating model. From that version onwards backwards compatibility is guaranteed in the Templating model by using .NET policies. This effectively means that any TBB built on a lower version than the CMS is running, will work without the need for recompilation against the latest version of ...